http://codeforces.com/contest/29
A
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define pb push_back 7 #define maxn 1000005 8 typedef long long ll; 9 typedef unsigned long long ull; 10 const ull MOD=257; 11 /*#ifndef ONLINE_JUDGE 12 freopen("1.txt","r",stdin); 13 #endif */ 14 15 16 int main(){ 17 #ifndef ONLINE_JUDGE 18 // freopen("1.txt","r",stdin); 19 #endif 20 std::ios::sync_with_stdio(false); 21 int n; 22 cin>>n; 23 int a[105],b[105]; 24 for(int i=1;i<=n;i++){ 25 cin>>a[i]>>b[i]; 26 } 27 int flag=0; 28 for(int i=1;i<=n;i++){ 29 for(int j=1;j<=n;j++){ 30 if(i!=j){ 31 if(a[i]+b[i]==a[j]&&a[j]+b[j]==a[i]){ 32 flag=1; 33 } 34 } 35 } 36 } 37 if(flag) cout<<"YES"<<endl; 38 else cout<<"NO"<<endl; 39 }