# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963455 | noobcodur | Remittance (JOI19_remittance) | C++14 | 166 ms | 36496 KiB |
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>
using namespace std;
using ld = long double;
#define int long long
#define pii pair<int,int>
#define forn(i,j) for(int i = 0; i < j; ++i)
#define forrange(i,j,k) for(int i = j; i < k; ++i)
#define vi vector<int>
#define vpii vector<pii>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
const int MOD = 1e9+7; const int INF = 1e17+1; const int maxN = 1e6+1;
void setIO(string name){
ios_base::sync_with_stdio(0);
cin.tie(0);
if(!name.empty()){
freopen((name + ".in").c_str(),"r",stdin);
freopen((name + ".out").c_str(),"w",stdout);
}
}
int a[maxN],b[maxN];
signed main(){
setIO("");
int n; cin >> n;
forn(i,n) cin >> a[i] >> b[i];
while(maxN){
int freq = 0;
forn(i,n){
if(a[i] <= b[i]) continue;
int x = (a[i]-b[i]+1)/2;
if(x && a[i] - 2*x >= 0){
a[i] -= 2*x;
a[(i+1) % n] += x;
freq++;
}
}
if(!freq) break;
}
forn(i,n){
if(a[i] != b[i]){
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |