codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

29A.md (1502B)


      1 Source: https://codeforces.com/problemset/problem/29/A
      2 
      3 A. Spit Problem
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 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.
     22 
     23 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.
     24 
     25 Input
     26 
     27 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 *x**i* and *d**i* ( - 104 ≤ *x**i* ≤ 104, 1 ≤ |*d**i*| ≤ 2·104) — records in Bob's notepad. *x**i* is a position of the *i*-th camel, and *d**i* is a distance at which the *i*-th camel spitted. Positive values of *d**i* correspond to the spits right, negative values correspond to the spits left. No two camels may stand in the same position.
     28 
     29 Output
     30 
     31 If there are two camels, which spitted at each other, output YES. Otherwise, output NO.
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 2  
     39 0 1  
     40 1 -1
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 YES
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 3  
     53 0 1  
     54 1 1  
     55 2 -2
     56 ```
     57 
     58 Output
     59 
     60 ```
     61 NO
     62 ```
     63 
     64 Input
     65 
     66 ```
     67 5  
     68 2 -10  
     69 3 10  
     70 0 5  
     71 5 -5  
     72 10 1
     73 ```
     74 
     75 Output
     76 
     77 ```
     78 YES
     79 ```