제출 #432076

#제출 시각아이디문제언어결과실행 시간메모리
432076OkMaybe송금 (JOI19_remittance)C++14
100 / 100
909 ms24804 KiB
/*input 2 1 1 2 2 */ #pragma GCC optimize ("O3") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; int main() { clock_t pradzia = clock(); ios_base::sync_with_stdio(false); int n; cin >> n; ll a[n], b[n]; for (int i = 0; i < n; i++) cin >> a[i] >> b[i]; while ((clock() - pradzia) * 10 <= 9 * CLOCKS_PER_SEC) { bool ok = true; for (int i = n - 1; i >= 0; i--) { if (a[i] < b[i]) { ll c = min(a[(i - 1 + n) % n] / 2, b[i] - a[i]); a[i] += c; a[(i - 1 + n) % n] -= 2 * c; ok = false; } } for (int i = 0; i < n; i++) { if (a[i] > b[i]) { ll c = min(a[i] / 2, (a[i] - b[i] + 1) / 2); a[i] -= c * 2; a[(i + 1) % n] += c; ok = false; } } if (ok) { cout << "Yes\n"; return 0; } } cout << "No\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...