Submission #492431

#TimeUsernameProblemLanguageResultExecution timeMemory
492431alextodoran송금 (JOI19_remittance)C++17
100 / 100
220 ms28544 KiB
/** ____ ____ ____ ____ ____ ||a |||t |||o |||d |||o || ||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\| **/ #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N_MAX = 1000000; int N; int A[N_MAX]; int B[N_MAX]; int main () { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N; for (int i = 0; i < N; i++) { cin >> A[i] >> B[i]; } bool all0 = true; for (int i = 0; i < N; i++) { if (A[i] != 0 || B[i] != 0) { all0 = false; } } if (all0 == true) { cout << "Yes\n"; return 0; } while (true) { bool complete = true; for (int i = 0; i < N; i++) { if (A[i] > B[i]) { int x = (A[i] - B[i] + 1) / 2; A[i] -= x * 2; A[(i + 1) % N] += x; if (x > 0) { complete = false; } } } if (complete == true) { break; } } bool answer = false; for (int i = 0; i < N; i++) { if (B[i] > 0) { answer = true; } } for (int i = 0; i < N; i++) { if (A[i] != B[i]) { answer = false; } } cout << (answer ? "Yes" : "No") << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...