This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
using namespace std;
const int N = 1e6+10;
ll a[N], b[N];
int n;
int main()
{
cin.tie(0) -> sync_with_stdio(false);
cin >> n;
Loop (i,0,n)
cin >> a[i] >> b[i];
Loop (_,0,100) {
Loop (i,0,n) {
ll x = max(0ll, (a[i] - b[i])/2);
a[i] -= 2*x;
a[(i+1) == n? 0: i+1] += x;
}
}
bool ans = 1;
Loop (i,0,n)
ans &= a[i] == b[i];
cout << (ans? "Yes": "No") << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |