C. Going Home
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
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 a.
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,w such that ax+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 n (4≤n≤200000) — the size of the array.
The second line contains n integers a1,a2,…,an (1≤ai≤2.5⋅106).
Output
Print “YES” if there are such four indices, and “NO” otherwise.
If such indices exist, print these indices x, y, z and w (1≤x,y,z,w≤n).
If there are multiple answers, print any of them.
鸽笼原理:
题目数据的值域是5e6;
也就是说在数据最极限的时候两个数的和从1到5e6都出现一边如果还有和没被算入那第5e6+1次就是答案了。这就是最极限了,超过这个还没出现答案也就是无解了,而一般解都在前面被算出来了。
所以暴力是能跑的。