제출 #1136866

#제출 시각아이디문제언어결과실행 시간메모리
1136866onbertRemittance (JOI19_remittance)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int maxn = 1e6 + 5, INF = 1e10; int n; int a[maxn], b[maxn]; signed main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i=0;i<n;i++) cin >> a[i] >> b[i]; bool odd = false; for (int i=1;i<n;i++) { int cur = a[i] + odd; odd = false; int give = max((cur - b[i] + 1) / 2, (int)0); if (b[i]==0) give = a[i] / 2, odd = true; a[i] -= give * 2, a[(i+1)%n] += give; // cout << a[i] << " " << give << endl; } for (int i=1;i<n;i++) { int take = max(b[i] - a[i], (int)0); if (b[i] == 0 && a[i] == 1) take = 1; // if (take > 0 && (i > 40 || ((int)1<<i) > INF / take)) {cout << "No\n"; return 0;} a[0] -= take * (1<<i); a[i] += take; if (a[0] < 0) {cout << "No\n"; return 0;} if (a[i] > b[i]) a[i] -= 2, a[(i+1)%n]++; } // if (a[0] > b[0]) { // if (n > 40) {cout << "No\n"; return 0;} // int diff = a[0] - b[0]; // int thing = ((int)1 << n); // if (diff % (thing-1) == 0 && a[0] - diff / (thing-1) * thing >= 0) cout << "Yes\n"; // else cout << "No\n"; // return 0; // } while (a[0] > b[0] && a[0] > (1<<n)) { a[0] -= (1 << n); a[0]++; } if (a[0] == b[0]) cout << "Yes\n"; else cout << "No\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...