跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F2463. Spit Problem

  • ID: 2469
  • 传统题
  • 2000ms
  • 256MiB
  • 尝试: 0
  • AC · 已通过: 0
  • 教学难度:入门
  • 上传者:
  • 枚举
  • 算法思想
  • 入门
  • 难度
  • 共享题库
  • Codeforces
  • 英文题面
  • 题目来源
  • 题面语言

Spit Problem

题目描述

A. Spit Problem
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 x spits d meters right, he can hit only the camel in position x+d, if such a camel exists.

Input

The first line contains integer n (1≤n≤100) − the amount of camels in the zoo. Each of the following n lines contains two integers xi and di (-104≤xi≤104,1≤|di|≤2·104) − records in Bob's notepad. xi is a position of the i-th camel, and di is a distance at which the i-th camel spitted. Positive values of di correspond to the spits right, negative values correspond to the spits left. No two camels may stand in the same position.

Output

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

Examples
Input
2
0 1
1 -1
Output
YES
Input
3
0 1
1 1
2 -2
Output
NO
Input
5
2 -10
3 10
0 5
5 -5
10 1
Output
YES

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 2097 题。保留原作者与原赛事署名。