답안 #513879

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
513879 2022-01-17T20:34:53 Z Vladth11 송금 (JOI19_remittance) C++14
100 / 100
405 ms 36396 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;

ll a[NMAX];
ll b[NMAX];
ll n;

ll nxt(ll i){
    i++;
    if(i > n)
        i = 1;
    return i;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i;
    cin >> n;
    ll needed = 0;
    for(i = 1; i <= n; i++){
        cin >> a[i] >> b[i];
    }
    for(ll tt = 1; tt <= nr_of_bits; tt++){
        for(i = 1; i <= n; i++){
            if(a[i] > b[i]){
                ll total = (a[i] - b[i] + 1) / 2;
                if(total * 2 > a[i])
                    total--;
                a[i] -= total * 2;
                a[nxt(i)] += total;
            }
        }
    }
    ll ok = 1;
    for(ll i = 1; i <= n; i++){
        if(a[i] != b[i])
            ok = 0;
    }
    if(ok) cout << "Yes";
    else cout << "No\n";
    return 0;
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:35:8: warning: unused variable 'needed' [-Wunused-variable]
   35 |     ll needed = 0;
      |        ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 204 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 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 0 ms 324 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 332 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 204 KB Output is correct
21 Correct 0 ms 316 KB Output is correct
22 Correct 0 ms 204 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 332 KB Output is correct
26 Correct 0 ms 320 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 324 KB Output is correct
31 Correct 1 ms 304 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 204 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 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 0 ms 324 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 332 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 204 KB Output is correct
21 Correct 0 ms 316 KB Output is correct
22 Correct 0 ms 204 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 332 KB Output is correct
26 Correct 0 ms 320 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 324 KB Output is correct
31 Correct 1 ms 304 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 0 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 0 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 328 KB Output is correct
41 Correct 0 ms 324 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 332 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 332 KB Output is correct
47 Correct 0 ms 332 KB Output is correct
48 Correct 0 ms 332 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 0 ms 328 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 324 KB Output is correct
54 Correct 1 ms 320 KB Output is correct
55 Correct 0 ms 324 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 0 ms 204 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 0 ms 204 KB Output is correct
62 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 204 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 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 0 ms 324 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 332 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 204 KB Output is correct
21 Correct 0 ms 316 KB Output is correct
22 Correct 0 ms 204 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 332 KB Output is correct
26 Correct 0 ms 320 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 324 KB Output is correct
31 Correct 1 ms 304 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 0 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 0 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 328 KB Output is correct
41 Correct 0 ms 324 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 332 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 332 KB Output is correct
47 Correct 0 ms 332 KB Output is correct
48 Correct 0 ms 332 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 0 ms 328 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 324 KB Output is correct
54 Correct 1 ms 320 KB Output is correct
55 Correct 0 ms 324 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 0 ms 204 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 0 ms 204 KB Output is correct
62 Correct 0 ms 332 KB Output is correct
63 Correct 247 ms 35204 KB Output is correct
64 Correct 151 ms 19912 KB Output is correct
65 Correct 251 ms 34916 KB Output is correct
66 Correct 176 ms 19868 KB Output is correct
67 Correct 161 ms 21200 KB Output is correct
68 Correct 166 ms 23556 KB Output is correct
69 Correct 238 ms 35312 KB Output is correct
70 Correct 155 ms 19872 KB Output is correct
71 Correct 165 ms 21264 KB Output is correct
72 Correct 174 ms 23624 KB Output is correct
73 Correct 244 ms 35276 KB Output is correct
74 Correct 166 ms 19912 KB Output is correct
75 Correct 155 ms 21144 KB Output is correct
76 Correct 167 ms 23544 KB Output is correct
77 Correct 244 ms 35324 KB Output is correct
78 Correct 362 ms 27572 KB Output is correct
79 Correct 366 ms 27528 KB Output is correct
80 Correct 209 ms 27560 KB Output is correct
81 Correct 218 ms 27676 KB Output is correct
82 Correct 312 ms 19876 KB Output is correct
83 Correct 146 ms 19900 KB Output is correct
84 Correct 141 ms 19868 KB Output is correct
85 Correct 273 ms 36396 KB Output is correct
86 Correct 298 ms 36320 KB Output is correct
87 Correct 405 ms 28544 KB Output is correct
88 Correct 231 ms 28668 KB Output is correct