이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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[1000001];
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |