# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
296433 | 2020-09-10T14:38:08 Z | BeanZ | 송금 (JOI19_remittance) | C++14 | 1 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 1e6 + 5; ll a[N], b[N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("balance.in", "r")){ freopen("balance.in", "r", stdin); freopen("balance.out", "w", stdout); } ll n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; while (true){ bool flag = false; for (int i = 1; i < n; i++){ if (a[i] <= b[i]) continue; ll rem = a[i] - b[i]; ll pass = rem / 2; if (pass == 0) continue; flag = true; a[i + 1] += pass; a[i] -= pass * 2; } if (a[n] > (b[n] + 1)){ ll rem = a[n] - b[n]; ll pass = rem / 2; flag = true; a[1] += pass; a[n] -= pass * 2; } if (!flag) break; } for (int i = 1; i <= n; i++){ if (a[i] != b[i]) return cout << "No", 0; } cout << "Yes"; } /* */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Incorrect | 0 ms | 384 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Incorrect | 0 ms | 384 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Incorrect | 0 ms | 384 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |