# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
773783 | 2023-07-05T08:28:55 Z | CyberCow | 송금 (JOI19_remittance) | C++17 | 612 ms | 16076 KB |
//#include <bits/stdc++.h> #include <random> #include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include <chrono> #define fr first #define sc second #define ad push_back using namespace std; using ll = long long; mt19937 rnd(348502); const int N = 1000005; ll a[N], b[N]; void solve() { ll n, i, j, x, y, gum1 = 0, gum = 0; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i] >> b[i]; gum += a[i]; gum1 += b[i]; } i = 0; int st = 0, qan = 0; while (1) { qan++; i++; if (i == n + 1) { int st = 1; for ( j = 1; j <= n; j++) { if (a[j] != b[j]) st = 0; } if (st) { cout << "Yes"; return; } i = 1; } if (i < n) { if (a[i] > b[i]) { if (a[i] - (a[i] - b[i] + 1) / 2 * 2 >= 0) { gum -= (a[i] - b[i] + 1) / 2 * 2; gum += (a[i] - b[i] + 1) / 2; a[i + 1] += (a[i] - b[i] + 1) / 2; a[i] -= (a[i] - b[i] + 1) / 2 * 2; } else { gum -= (a[i] - b[i] + 1) / 2 * 2 - 2; gum += (a[i] - b[i] + 1) / 2 - 1; a[i + 1] += (a[i] - b[i] + 1) / 2 - 1; a[i] -= (a[i] - b[i] + 1) / 2 * 2 - 2; } } } else { if (a[i] > b[i]) { if (a[i] - (a[i] - b[i] + 1) / 2 * 2 >= 0) { gum -= (a[i] - b[i] + 1) / 2 * 2; gum += (a[i] - b[i] + 1) / 2; a[1] += (a[i] - b[i] + 1) / 2; a[i] -= (a[i] - b[i] + 1) / 2 * 2; } else { gum -= (a[i] - b[i] + 1) / 2 * 2 - 2; gum += (a[i] - b[i] + 1) / 2 - 1; a[1] += (a[i] - b[i] + 1) / 2 - 1; a[i] -= (a[i] - b[i] + 1) / 2 * 2 - 2; } } } if (qan >= 100000000) break; } if (n <= 7) { if (gum == gum1) cout << "Yes"; else cout << "No"; } else { if(gum == gum1) cout << "Yes"; else cout << "No"; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll tt = 1; //cin >> tt; while (tt--) { solve(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 246 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 156 ms | 316 KB | Output is correct |
13 | Correct | 152 ms | 340 KB | Output is correct |
14 | Correct | 180 ms | 316 KB | Output is correct |
15 | Correct | 136 ms | 320 KB | Output is correct |
16 | Correct | 310 ms | 340 KB | Output is correct |
17 | Correct | 202 ms | 316 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 159 ms | 340 KB | Output is correct |
20 | Correct | 395 ms | 340 KB | Output is correct |
21 | Correct | 396 ms | 312 KB | Output is correct |
22 | Correct | 157 ms | 340 KB | Output is correct |
23 | Correct | 322 ms | 316 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 162 ms | 316 KB | Output is correct |
26 | Correct | 400 ms | 340 KB | Output is correct |
27 | Correct | 141 ms | 316 KB | Output is correct |
28 | Correct | 0 ms | 212 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 136 ms | 340 KB | Output is correct |
31 | Correct | 395 ms | 316 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 246 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 156 ms | 316 KB | Output is correct |
13 | Correct | 152 ms | 340 KB | Output is correct |
14 | Correct | 180 ms | 316 KB | Output is correct |
15 | Correct | 136 ms | 320 KB | Output is correct |
16 | Correct | 310 ms | 340 KB | Output is correct |
17 | Correct | 202 ms | 316 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 159 ms | 340 KB | Output is correct |
20 | Correct | 395 ms | 340 KB | Output is correct |
21 | Correct | 396 ms | 312 KB | Output is correct |
22 | Correct | 157 ms | 340 KB | Output is correct |
23 | Correct | 322 ms | 316 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 162 ms | 316 KB | Output is correct |
26 | Correct | 400 ms | 340 KB | Output is correct |
27 | Correct | 141 ms | 316 KB | Output is correct |
28 | Correct | 0 ms | 212 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 136 ms | 340 KB | Output is correct |
31 | Correct | 395 ms | 316 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 129 ms | 320 KB | Output is correct |
34 | Correct | 0 ms | 340 KB | Output is correct |
35 | Correct | 0 ms | 340 KB | Output is correct |
36 | Correct | 0 ms | 340 KB | Output is correct |
37 | Correct | 0 ms | 212 KB | Output is correct |
38 | Correct | 0 ms | 340 KB | Output is correct |
39 | Correct | 0 ms | 340 KB | Output is correct |
40 | Correct | 0 ms | 340 KB | Output is correct |
41 | Correct | 1 ms | 340 KB | Output is correct |
42 | Correct | 176 ms | 340 KB | Output is correct |
43 | Correct | 138 ms | 320 KB | Output is correct |
44 | Correct | 131 ms | 320 KB | Output is correct |
45 | Correct | 137 ms | 316 KB | Output is correct |
46 | Correct | 170 ms | 316 KB | Output is correct |
47 | Correct | 147 ms | 212 KB | Output is correct |
48 | Correct | 129 ms | 340 KB | Output is correct |
49 | Correct | 0 ms | 340 KB | Output is correct |
50 | Correct | 427 ms | 316 KB | Output is correct |
51 | Correct | 402 ms | 316 KB | Output is correct |
52 | Correct | 290 ms | 316 KB | Output is correct |
53 | Correct | 375 ms | 212 KB | Output is correct |
54 | Correct | 0 ms | 340 KB | Output is correct |
55 | Correct | 131 ms | 316 KB | Output is correct |
56 | Correct | 400 ms | 320 KB | Output is correct |
57 | Correct | 127 ms | 320 KB | Output is correct |
58 | Correct | 1 ms | 340 KB | Output is correct |
59 | Correct | 0 ms | 212 KB | Output is correct |
60 | Correct | 130 ms | 316 KB | Output is correct |
61 | Correct | 410 ms | 320 KB | Output is correct |
62 | Correct | 0 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 246 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 156 ms | 316 KB | Output is correct |
13 | Correct | 152 ms | 340 KB | Output is correct |
14 | Correct | 180 ms | 316 KB | Output is correct |
15 | Correct | 136 ms | 320 KB | Output is correct |
16 | Correct | 310 ms | 340 KB | Output is correct |
17 | Correct | 202 ms | 316 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 159 ms | 340 KB | Output is correct |
20 | Correct | 395 ms | 340 KB | Output is correct |
21 | Correct | 396 ms | 312 KB | Output is correct |
22 | Correct | 157 ms | 340 KB | Output is correct |
23 | Correct | 322 ms | 316 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 162 ms | 316 KB | Output is correct |
26 | Correct | 400 ms | 340 KB | Output is correct |
27 | Correct | 141 ms | 316 KB | Output is correct |
28 | Correct | 0 ms | 212 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 136 ms | 340 KB | Output is correct |
31 | Correct | 395 ms | 316 KB | Output is correct |
32 | Correct | 0 ms | 340 KB | Output is correct |
33 | Correct | 129 ms | 320 KB | Output is correct |
34 | Correct | 0 ms | 340 KB | Output is correct |
35 | Correct | 0 ms | 340 KB | Output is correct |
36 | Correct | 0 ms | 340 KB | Output is correct |
37 | Correct | 0 ms | 212 KB | Output is correct |
38 | Correct | 0 ms | 340 KB | Output is correct |
39 | Correct | 0 ms | 340 KB | Output is correct |
40 | Correct | 0 ms | 340 KB | Output is correct |
41 | Correct | 1 ms | 340 KB | Output is correct |
42 | Correct | 176 ms | 340 KB | Output is correct |
43 | Correct | 138 ms | 320 KB | Output is correct |
44 | Correct | 131 ms | 320 KB | Output is correct |
45 | Correct | 137 ms | 316 KB | Output is correct |
46 | Correct | 170 ms | 316 KB | Output is correct |
47 | Correct | 147 ms | 212 KB | Output is correct |
48 | Correct | 129 ms | 340 KB | Output is correct |
49 | Correct | 0 ms | 340 KB | Output is correct |
50 | Correct | 427 ms | 316 KB | Output is correct |
51 | Correct | 402 ms | 316 KB | Output is correct |
52 | Correct | 290 ms | 316 KB | Output is correct |
53 | Correct | 375 ms | 212 KB | Output is correct |
54 | Correct | 0 ms | 340 KB | Output is correct |
55 | Correct | 131 ms | 316 KB | Output is correct |
56 | Correct | 400 ms | 320 KB | Output is correct |
57 | Correct | 127 ms | 320 KB | Output is correct |
58 | Correct | 1 ms | 340 KB | Output is correct |
59 | Correct | 0 ms | 212 KB | Output is correct |
60 | Correct | 130 ms | 316 KB | Output is correct |
61 | Correct | 410 ms | 320 KB | Output is correct |
62 | Correct | 0 ms | 340 KB | Output is correct |
63 | Correct | 371 ms | 15964 KB | Output is correct |
64 | Correct | 93 ms | 15876 KB | Output is correct |
65 | Correct | 159 ms | 15952 KB | Output is correct |
66 | Correct | 87 ms | 15840 KB | Output is correct |
67 | Correct | 95 ms | 15868 KB | Output is correct |
68 | Correct | 102 ms | 15960 KB | Output is correct |
69 | Correct | 157 ms | 15936 KB | Output is correct |
70 | Correct | 256 ms | 15948 KB | Output is correct |
71 | Correct | 270 ms | 15960 KB | Output is correct |
72 | Correct | 270 ms | 15888 KB | Output is correct |
73 | Correct | 324 ms | 15868 KB | Output is correct |
74 | Correct | 262 ms | 15896 KB | Output is correct |
75 | Correct | 259 ms | 15872 KB | Output is correct |
76 | Correct | 280 ms | 15964 KB | Output is correct |
77 | Correct | 317 ms | 15936 KB | Output is correct |
78 | Correct | 571 ms | 16076 KB | Output is correct |
79 | Correct | 612 ms | 15964 KB | Output is correct |
80 | Correct | 132 ms | 15932 KB | Output is correct |
81 | Correct | 290 ms | 16020 KB | Output is correct |
82 | Correct | 534 ms | 15964 KB | Output is correct |
83 | Correct | 246 ms | 15968 KB | Output is correct |
84 | Correct | 76 ms | 15860 KB | Output is correct |
85 | Correct | 165 ms | 15884 KB | Output is correct |
86 | Correct | 336 ms | 15968 KB | Output is correct |
87 | Correct | 579 ms | 15964 KB | Output is correct |
88 | Correct | 137 ms | 15944 KB | Output is correct |