Submission #672235

#TimeUsernameProblemLanguageResultExecution timeMemory
672235HanksburgerRemittance (JOI19_remittance)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; long long a[1000005], b[1000005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, l=0, r=1e9; cin >> n; for (long long i=1; i<=n; i++) cin >> a[i] >> b[i]; while (l<r) { long long m=(l+r)/2; for (long long i=n; i>=1; i--) { m=m*2-a[i]+b[i]; if (m<0 || m>1e9) break; } if (m<(l+r)/2) l=(l+r)/2+1; else r=(l+r)/2; } for (long long i=n; i>=1; i--) { l=l*2-a[i]+b[i]; if (l<0 || l>1e9) break; } bool ok=0; if (l==r) { for (long long i=1; i<=n; i++) { if (b[i]) { ok=1; break; } } } cout << (ok?"Yes":"No"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...