# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
773733 | 2023-07-05T08:02:08 Z | CyberCow | 송금 (JOI19_remittance) | C++17 | 156 ms | 340 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], kop[N]; void solve() { ll n, i, j, x, y, gg = 0, gg1 = 0, gum1 = 0, gum = 0; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i] >> b[i]; gg += a[i]; gg1 += b[i]; kop[i] = a[i]; } for (int h = 0; h < n - 1; h++) { for ( i = 1; i <= n; i++) { a[i] = kop[i]; } int st = 0, qan = 0; gum = gg; gum1 = gg1; i = 0; while (gum >= gum1) { qan++; i++; if (i == n + 1) { if (st == n) break; i = 1; st = 0; } 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 { 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; } } } if (a[i] == b[i]) st++; if (qan >= 100000000) break; } if (gum == gum1) { cout << "Yes"; return; } gg -= kop[i] / 2 * 2; gg1 += kop[i] / 2; kop[i + 1] += kop[i] / 2; kop[i] -= kop[i] / 2 * 2; } 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 | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Incorrect | 156 ms | 340 KB | Output isn't correct |
17 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Incorrect | 156 ms | 340 KB | Output isn't correct |
17 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Incorrect | 156 ms | 340 KB | Output isn't correct |
17 | Halted | 0 ms | 0 KB | - |