CF29A.Spit Problem

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In a Berland's zoo there is an enclosure with camels. It is known that camels like to spit. Bob watched these interesting animals for the whole day and registered in his notepad where each animal spitted. Now he wants to know if in the zoo there are two camels, which spitted at each other. Help him to solve this task.

The trajectory of a camel's spit is an arc, i.e. if the camel in position xx spits dd meters right, he can hit only the camel in position x+dx+d , if such a camel exists.

输入格式

The first line contains integer nn ( 1<=n<=1001<=n<=100 ) — the amount of camels in the zoo. Each of the following nn lines contains two integers xix_{i} and did_{i} ( 104<=xi<=104,1<=di<=2104-10^{4}<=x_{i}<=10^{4},1<=|d_{i}|<=2·10^{4} ) — records in Bob's notepad. xix_{i} is a position of the ii -th camel, and did_{i} is a distance at which the ii -th camel spitted. Positive values of did_{i} correspond to the spits right, negative values correspond to the spits left. No two camels may stand in the same position.

输出格式

If there are two camels, which spitted at each other, output YES. Otherwise, output NO.

输入输出样例

  • 输入#1

    2
    0 1
    1 -1
    

    输出#1

    YES
    
  • 输入#2

    3
    0 1
    1 1
    2 -2
    

    输出#2

    NO
    
  • 输入#3

    5
    2 -10
    3 10
    0 5
    5 -5
    10 1
    

    输出#3

    YES
    
首页