Submission #906608

#TimeUsernameProblemLanguageResultExecution timeMemory
906608mickey080929Remittance (JOI19_remittance)C++17
100 / 100
828 ms36444 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll A[1000010]; ll B[1000010]; int main() { ll N; cin >> N; for (ll i=0; i<N; i++) { cin >> A[i] >> B[i]; } for (ll loop=0; loop<30; loop++) { for (ll i=0; i<N; i++) { if (B[i] < A[i]) { ll t = (A[i] - B[i]) / 2; A[i] -= t * 2; A[(i+1)%N] += t; } } } bool diff = false, notone = false; for (ll i=0; i<N; i++) { if (A[i] != B[i]) { diff = true; } if (A[i] != 1) notone = true; } if (!diff) cout << "Yes\n"; else if (!notone) cout << "No\n"; else { for (ll i=0; i<N; i++) { if (A[i] - 1 != B[i]) { cout << "No\n"; return 0; } } cout << "Yes\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...