# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
483413 | 2021-10-29T09:31:40 Z | Lam_lai_cuoc_doi | 송금 (JOI19_remittance) | C++17 | 223 ms | 36296 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; template <class T> void read(T &x) { x = 0; register int c; while ((c = getchar()) && (c > '9' || c < '0')) ; for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0'; } constexpr bool typetest = 0; constexpr int N = 1e6 + 5; int n; ll a[N], b[N]; void Read() { cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i] >> b[i]; } void Send(int pos, ll v) { a[pos] -= v * 2; ++pos; if (pos > n) pos = 1; a[pos] += v; } void Solve() { while (1) { bool ok(1); for (int i = 1; i <= n; ++i) if (a[i] > b[i]) { ll v = (a[i] - b[i]) / 2; if (v == 0 && a[i] > 1) Send(i, 1), ok = 0; if (v > 0) Send(i, v), ok = 0; } if (ok) break; } for (int i = 1; i <= n; ++i) if (a[i] != b[i]) { cout << "No"; return; } cout << "Yes"; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t(1); if (fopen(".INP", "r")) { freopen("and.inp", "r", stdin); freopen("and.out", "w", stdout); } if (typetest) cin >> t; for (int _ = 1; _ <= t; ++_) { // cout << "Case #" << _ << ": "; Read(); Solve(); } // cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 0 ms | 204 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 0 ms | 204 KB | Output is correct |
20 | Correct | 0 ms | 332 KB | Output is correct |
21 | Correct | 0 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 316 KB | Output is correct |
23 | Correct | 0 ms | 332 KB | Output is correct |
24 | Correct | 0 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 1 ms | 204 KB | Output is correct |
27 | Correct | 0 ms | 204 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 0 ms | 332 KB | Output is correct |
30 | Correct | 0 ms | 320 KB | Output is correct |
31 | Correct | 0 ms | 204 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 0 ms | 204 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 0 ms | 204 KB | Output is correct |
20 | Correct | 0 ms | 332 KB | Output is correct |
21 | Correct | 0 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 316 KB | Output is correct |
23 | Correct | 0 ms | 332 KB | Output is correct |
24 | Correct | 0 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 1 ms | 204 KB | Output is correct |
27 | Correct | 0 ms | 204 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 0 ms | 332 KB | Output is correct |
30 | Correct | 0 ms | 320 KB | Output is correct |
31 | Correct | 0 ms | 204 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 0 ms | 332 KB | Output is correct |
34 | Correct | 0 ms | 204 KB | Output is correct |
35 | Correct | 1 ms | 332 KB | Output is correct |
36 | Correct | 0 ms | 332 KB | Output is correct |
37 | Correct | 1 ms | 332 KB | Output is correct |
38 | Correct | 1 ms | 332 KB | Output is correct |
39 | Correct | 1 ms | 324 KB | Output is correct |
40 | Correct | 0 ms | 332 KB | Output is correct |
41 | Correct | 0 ms | 332 KB | Output is correct |
42 | Correct | 1 ms | 332 KB | Output is correct |
43 | Correct | 0 ms | 332 KB | Output is correct |
44 | Correct | 0 ms | 332 KB | Output is correct |
45 | Correct | 0 ms | 204 KB | Output is correct |
46 | Correct | 1 ms | 204 KB | Output is correct |
47 | Correct | 0 ms | 332 KB | Output is correct |
48 | Correct | 1 ms | 332 KB | Output is correct |
49 | Correct | 0 ms | 332 KB | Output is correct |
50 | Correct | 1 ms | 204 KB | Output is correct |
51 | Correct | 0 ms | 332 KB | Output is correct |
52 | Correct | 0 ms | 332 KB | Output is correct |
53 | Correct | 0 ms | 332 KB | Output is correct |
54 | Correct | 0 ms | 332 KB | Output is correct |
55 | Correct | 0 ms | 332 KB | Output is correct |
56 | Correct | 0 ms | 320 KB | Output is correct |
57 | Correct | 0 ms | 332 KB | Output is correct |
58 | Correct | 0 ms | 332 KB | Output is correct |
59 | Correct | 0 ms | 332 KB | Output is correct |
60 | Correct | 0 ms | 332 KB | Output is correct |
61 | Correct | 1 ms | 204 KB | Output is correct |
62 | Correct | 1 ms | 252 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 0 ms | 204 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 0 ms | 204 KB | Output is correct |
20 | Correct | 0 ms | 332 KB | Output is correct |
21 | Correct | 0 ms | 204 KB | Output is correct |
22 | Correct | 1 ms | 316 KB | Output is correct |
23 | Correct | 0 ms | 332 KB | Output is correct |
24 | Correct | 0 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 204 KB | Output is correct |
26 | Correct | 1 ms | 204 KB | Output is correct |
27 | Correct | 0 ms | 204 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 0 ms | 332 KB | Output is correct |
30 | Correct | 0 ms | 320 KB | Output is correct |
31 | Correct | 0 ms | 204 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 0 ms | 332 KB | Output is correct |
34 | Correct | 0 ms | 204 KB | Output is correct |
35 | Correct | 1 ms | 332 KB | Output is correct |
36 | Correct | 0 ms | 332 KB | Output is correct |
37 | Correct | 1 ms | 332 KB | Output is correct |
38 | Correct | 1 ms | 332 KB | Output is correct |
39 | Correct | 1 ms | 324 KB | Output is correct |
40 | Correct | 0 ms | 332 KB | Output is correct |
41 | Correct | 0 ms | 332 KB | Output is correct |
42 | Correct | 1 ms | 332 KB | Output is correct |
43 | Correct | 0 ms | 332 KB | Output is correct |
44 | Correct | 0 ms | 332 KB | Output is correct |
45 | Correct | 0 ms | 204 KB | Output is correct |
46 | Correct | 1 ms | 204 KB | Output is correct |
47 | Correct | 0 ms | 332 KB | Output is correct |
48 | Correct | 1 ms | 332 KB | Output is correct |
49 | Correct | 0 ms | 332 KB | Output is correct |
50 | Correct | 1 ms | 204 KB | Output is correct |
51 | Correct | 0 ms | 332 KB | Output is correct |
52 | Correct | 0 ms | 332 KB | Output is correct |
53 | Correct | 0 ms | 332 KB | Output is correct |
54 | Correct | 0 ms | 332 KB | Output is correct |
55 | Correct | 0 ms | 332 KB | Output is correct |
56 | Correct | 0 ms | 320 KB | Output is correct |
57 | Correct | 0 ms | 332 KB | Output is correct |
58 | Correct | 0 ms | 332 KB | Output is correct |
59 | Correct | 0 ms | 332 KB | Output is correct |
60 | Correct | 0 ms | 332 KB | Output is correct |
61 | Correct | 1 ms | 204 KB | Output is correct |
62 | Correct | 1 ms | 252 KB | Output is correct |
63 | Correct | 208 ms | 35248 KB | Output is correct |
64 | Correct | 141 ms | 19784 KB | Output is correct |
65 | Correct | 223 ms | 34756 KB | Output is correct |
66 | Correct | 107 ms | 19840 KB | Output is correct |
67 | Correct | 122 ms | 21204 KB | Output is correct |
68 | Correct | 137 ms | 23620 KB | Output is correct |
69 | Correct | 197 ms | 35292 KB | Output is correct |
70 | Correct | 111 ms | 19752 KB | Output is correct |
71 | Correct | 126 ms | 21192 KB | Output is correct |
72 | Correct | 132 ms | 23564 KB | Output is correct |
73 | Correct | 202 ms | 35288 KB | Output is correct |
74 | Correct | 105 ms | 19780 KB | Output is correct |
75 | Correct | 126 ms | 21204 KB | Output is correct |
76 | Correct | 141 ms | 23600 KB | Output is correct |
77 | Correct | 197 ms | 35244 KB | Output is correct |
78 | Correct | 147 ms | 27460 KB | Output is correct |
79 | Correct | 148 ms | 27532 KB | Output is correct |
80 | Correct | 159 ms | 27604 KB | Output is correct |
81 | Correct | 152 ms | 27528 KB | Output is correct |
82 | Correct | 99 ms | 19804 KB | Output is correct |
83 | Correct | 107 ms | 19860 KB | Output is correct |
84 | Correct | 95 ms | 19752 KB | Output is correct |
85 | Correct | 223 ms | 36296 KB | Output is correct |
86 | Correct | 215 ms | 36292 KB | Output is correct |
87 | Correct | 171 ms | 28544 KB | Output is correct |
88 | Correct | 190 ms | 28652 KB | Output is correct |