Submission #922789

#TimeUsernameProblemLanguageResultExecution timeMemory
922789phoenix0423Remittance (JOI19_remittance)C++17
0 / 100
1 ms588 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pll; #define fastio ios::sync_with_stdio(false), cin.tie(0) #define pb push_back #define eb emplace_back #define f first #define s second #define int long long const int INF = 1e18; signed main(void){ fastio; int n; cin>>n; vector<int> a(n); for(int i = 0; i < n; i++){ int x, y; cin>>x>>y; a[i] = x - y; } for(int i = 0; i < n; i++){ if(a[i] > 0 && a[i] % 2){ int nd = 2; int id = (i - 1 + n) % n; while(id != i && a[id] < nd){ nd -= a[id], a[id] = 0; nd *= 2; id = (id - 1 + n) % n; } if(id == i){ cout<<"No\n"; return 0; } a[id] -= nd; a[i] ++; } } for(int i = 0; i < n; i++){ if(a[i] < 0){ int nd = - a[i] * 2; int id = (i - 1 + n) % n; while(id != i && a[id] < nd){ nd -= a[id], a[id] = 0; nd *= 2; id = (id - 1 + n) % n; } if(id == i){ cout<<"No\n"; return 0; } a[id] -= nd; a[i] = 0; } } for(auto x : a){ if(x){ cout<<"No\n"; return 0; } } cout<<"Yes\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...