제출 #158530

#제출 시각아이디문제언어결과실행 시간메모리
158530bicsi송금 (JOI19_remittance)C++14
55 / 100
1068 ms30096 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long> a(n), b(n); for (int i = 0; i < n; ++i) cin >> a[i] >> b[i]; int ch = 1; while (ch--) { for (int i = 0; i < n; ++i) { if (a[i] > b[i]) { long long take = (a[i] - b[i]) / 2; a[i] -= 2 * take; if (a[i] > b[i] && a[i] > 1) { a[i] -= 2; take += 1; } a[(i + 1) % n] += take; if (take > 0) ch = 1; } } } for (int i = 0; i < n; ++i) { if (a[i] != 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...