# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
513874 | 2022-01-17T20:26:13 Z | Vladth11 | Remittance (JOI19_remittance) | C++14 | 1 ms | 332 KB |
#include <bits/stdc++.h> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " using namespace std; typedef long long ll; typedef pair <ll, ll> pii; typedef pair <long double, pii> muchie; const ll NMAX = 10000001; const ll VMAX = 21; const ll INF = (1LL << 60); const ll MOD = 1000000007; const ll BLOCK = 318; const ll base = 31; const ll nr_of_bits = 60; int a[NMAX]; int b[NMAX]; int n; int nxt(int i){ i++; if(i > n) i = 1; return i; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int i; cin >> n; int needed = 0; for(i = 1; i <= n; i++){ cin >> a[i] >> b[i]; } for(int tt = 1; tt <= nr_of_bits; tt++){ for(i = 1; i <= n; i++){ if(a[i] > b[i] && (a[i] - b[i]) / 2 != 0){ break; } } if(i == n + 1) break; int total = (a[i] - b[i]) / 2; a[i] -= total * 2; a[nxt(i)] += total; for(int j = nxt(i); j != i; j = nxt(j)){ if(a[j] <= b[j]) break; total = (a[j] - b[j]) / 2; a[j] -= total * 2; a[nxt(j)] += total; } } int ok = 1; for(int i = 1; i <= n; i++){ if(a[i] != b[i]) ok = 0; } if(ok) cout << "Yes"; else cout << "No\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 308 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 320 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Incorrect | 0 ms | 316 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 308 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 320 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Incorrect | 0 ms | 316 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 308 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 320 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Incorrect | 0 ms | 316 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |