2021-04-28

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次就是答案了。这就是最极限了,超过这个还没出现答案也就是无解了,而一般解都在前面被算出来了。
所以暴力是能跑的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值