Submission #1121299

#TimeUsernameProblemLanguageResultExecution timeMemory
1121299Dan4LifeRemittance (JOI19_remittance)C++17
0 / 100
2 ms596 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a),end(a) #define int long long const int N = (int)1e6+10; int n, a[N], b[N]; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; int ok = 1; for(int i = 0; i < n; i++) cin >> a[i] >> b[i]; int xd = n+100000, i = 1; while(xd--){ int nx = (i+1==n?0:i+1); int tot = (a[i]-b[i]+1)/2; if(a[i]>b[i]) a[nx]+=tot,a[i]-=tot*2; i = nx; } for(int i = 0; i < n; i++) ok&=(a[i]==b[i]); cout << (ok?"Yes":"No") << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...