Submission #431737

#TimeUsernameProblemLanguageResultExecution timeMemory
431737kostia244Remittance (JOI19_remittance)C++17
100 / 100
499 ms28576 KiB
#pragma GCC optimize("trapv") #include<bits/stdc++.h> using namespace std; const int N = 1e6 + 16; int n, a[N], b[N]; int main() { cin.tie(0)->sync_with_stdio(0); cin >> n; for(int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } for(int z = 30; z--;){ for(int i = 0; i+1 < n; i++) { if(a[i] > b[i]) { a[i+1] += (a[i]-b[i]+(b[i]>0))/2; a[i] -= 2*((a[i]-b[i]+(b[i]>0))/2); } } //for(int i = 0; i < n; i++) cout << a[i] << " " << b[i] << endl; if(a[n-1] > b[n-1]) { a[0] += (a[n-1]-b[n-1]+(b[n-1]>0))/2; a[n-1] -= 2*((a[n-1]-b[n-1]+(b[n-1]>0))/2); } //for(int i = 0; i < n; i++) cout << a[i] << " " << b[i] << endl; } int ok = 1; 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...