# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
683343 | 2023-01-18T08:20:15 Z | tht2005 | Remittance (JOI19_remittance) | C++17 | 2 ms | 596 KB |
#include <bits/stdc++.h> using namespace std; #define N 1000006 int a[N], b[N]; long long X[N]; int main() { freopen("remittance.inp", "r", stdin); freopen("remittance.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; long long S = 0; for(int i = 1; i <= n; ++i) { cin >> a[i] >> b[i]; S += (long long)(b[i] - a[i]) << (i - 1); } if(S % (1 - (1LL << n)) != 0) { cout << "No"; return 0; } X[n] = S / (1 - (1LL << n)); if(X[n] < 0) { cout << "No"; return 0; } X[0] = X[n]; for(int i = 1; i < n; ++i) { long long val = X[i - 1] + a[i] - b[i]; if(val < 0 || (val & 1)) { cout << "No"; return 0; } X[i] = val >> 1; } cout << "Yes"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 596 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 596 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 596 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |