#include<bits/stdc++.h>
#define ll long long
#define f first
#define sc second
#define pb push_back
using namespace std;
ll a,b,c,d,i,e,f,g,n,m,k,l;
pair <ll,ll> A[500005];
int main() {
cin>>n;
for(ll i=1;i<=n;i++) {
cin>>A[i].f>>A[i].sc;
}
for(ll i=1;i<=n;i++) {
if(A[i].f<=A[i].sc) continue;
a=A[i].f-A[i].sc;
if(i==n) A[1].f+=a/2;
else A[i+1].f+=a/2;
A[i].f=A[i].sc+a%2;
}
for(ll i=1;i<=n;i++) {
if(A[i].f<=A[i].sc) continue;
a=A[i].f-A[i].sc;
if(i==n) A[1].f+=a/2;
else A[i+1].f+=a/2;
A[i].f=A[i].sc+a%2;
}
for(ll i=1;i<=n;i++) {
if(A[i].f<=A[i].sc) continue;
a=A[i].f-A[i].sc;
if(i==n) A[1].f+=a/2;
else A[i+1].f+=a/2;
A[i].f=A[i].sc+a%2;
}
a=0;
for(ll i=1;i<=n;i++) {
if(A[i].f!=A[i].sc) a=1;
}
if(a==1) cout<<"No";
else cout<<"Yes";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |