#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef pair<int, int> pii;
#define ff first
#define ss second
#define pb emplace_back
#define AI(x) begin(x),end(x)
template<class I> bool chmin(I&a, I b){ return a > b ? (a=b, true) : false; }
template<class I> bool chmax(I&a, I b){ return a < b ? (a=b, true) : false; }
#ifdef OWO
#define debug(args...) LKJ("\033[1;32m[ " + string(#args) + " ]\033[0m", args)
template<class I> void LKJ(I&&x){ cerr << x << endl; }
template<class I, class...T> void LKJ(I&&x, T&&...t){ cerr << x << ", "; LKJ(t...); }
template<class I> void OI(I a, I b){ while(a < b) cerr << *a << " \n"[next(a) == b], ++a; }
#else
#define debug(...) 0
#define OI(...) 0
#endif
const int kN = 1000001;
const int kL = 30;
int N, A[kN], B[kN];
void gg(){
cout << "No\n";
exit(0);
}
void input(){
cin >> N;
for(int i = 1; i <= N; ++i)
cin >> A[i] >> B[i];
}
void solve(){
for(int k = 0; k < 3; ++k){
ll cur = 0;
for(int i = 1; i <= N; ++i){
if(A[i] < B[i]){
ll t = B[i] - A[i];
ll x = min(cur, t);
cur -= x; A[i] += x;
if(cur & 1) --cur, ++A[i];
cur >>= 1;
} else {
ll t = A[i] - B[i];
cur += t; A[i] -= t;
if(cur & 1) --cur, ++A[i];
cur >>= 1;
}
}
A[1] += cur;
}
ll del = A[1] - B[1];
for(int i = 1; i <= N; ++i)
if(A[i] - B[i] != del) gg();
bool has = false;
for(int i = 1; i <= N; ++i)
has |= (A[i] >= 2);
if(!has) gg();
cout << "Yes\n";
return;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
input();
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |