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>
#include<unordered_map>
#include<unordered_set>
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define trav(a,v) for(auto& a: v)
#define sz(v) v.size()
#define all(v) v.begin(),v.end()
#define vi vector<int>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const long long inf = 2e9;
using namespace std;
int main() {
cin.sync_with_stdio(false);
ll n;
cin >> n;
vector<ll> a(n);
vector<ll> b(n);
rep(i, 0, n)cin >> a[i] >> b[i];
rep(i, 0, n*50) {
ll ind = i % n;
ll nxt = (i + 1) % n;
if (a[ind] <= b[ind])continue;
ll change = a[ind] - b[ind];
change += change % 2;
if (a[ind] < change)continue;
a[nxt] += change/2;
a[ind] -= change;
}
if (a == b)cout << "Yes";
else cout << "No";
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... |