0% found this document useful (0 votes)
37 views

Code 8

Nastya was given an integer array on a train ride home from school to entertain herself. She had to determine if there were four indices in the array where the sum of the elements at two indices equals the sum of the elements at the other two indices before arriving at her destination.

Uploaded by

Md.Amdad Hossain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Code 8

Nastya was given an integer array on a train ride home from school to entertain herself. She had to determine if there were four indices in the array where the sum of the elements at two indices equals the sum of the elements at the other two indices before arriving at her destination.

Uploaded by

Md.Amdad Hossain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to

return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented
her an integer array aa.

Several hours after starting her journey home Nastya remembered about the present. To entertain
herself she decided to check, are there four different indices x,y,z,wx,y,z,w such
that ax+ay=az+awax+ay=az+aw.

Her train has already arrived the destination, but she still hasn't found the answer. Can you help her
unravel the mystery?
Input
The first line contains the single integer nn (4≤n≤2000004≤n≤200000) — the size of the array.
The second line contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤2.5⋅1061≤ai≤2.5⋅106).
Output

Print "YES" if there are such four indices, and "NO" otherwise.
If such indices exist, print these indices xx, yy, zz and ww (1≤x,y,z,w≤n1≤x,y,z,w≤n).

If there are multiple answers, print any of them.

You might also like