Submission #140636

#TimeUsernameProblemLanguageResultExecution timeMemory
140636MatheusLealVRemittance (JOI19_remittance)C++17
100 / 100
546 ms32552 KiB
#include <bits/stdc++.h> #define N 1000020 using namespace std; int n, a[N], b[N], t[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin>>n; for(int i = 0; i < n; i++) { cin>>a[i]>>b[i]; t[i] = a[i] - b[i]; } for(int c = 0; c < 40; c++) { for(int i = 0; i < n; i++) { if(t[i] > 0) { int dt = min(a[i]/2, (t[i] + 1)/2); t[i] -= 2*dt; a[i] -= 2*dt; t[(i + 1)%n] += dt; a[(i + 1)%n] += dt; } } } for(int i = 0; i < n; i++) if(t[i]) { 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...