#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
llo n;
pair<llo,llo> it[100001];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
for(llo i=0;i<n;i++){
cin>>it[i].a>>it[i].b;
}
llo su=0;
llo cur=1;
for(llo i=1;i<n;i++){
su+=(it[i].a-it[i].b)*cur;
cur*=2;
}
su+=cur*(it[0].a-it[0].b);
cur*=2;
cur-=1;
if(su<0){
cout<<"NO"<<endl;
}
else{
if(su%cur>0){
cout<<"NO"<<endl;
}
else{
llo ac=su/cur;
for(llo i=1;i<n;i++){
llo cc=it[i].a-it[i].b+ac;
if(cc<0){
cout<<"NO"<<endl;
return 0;
}
if(cc%2>0){
cout<<"NO"<<endl;
return 0;
}
ac=cc/2;
}
cout<<"YES"<<endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |