답안 #233322

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
233322 2020-05-20T09:07:43 Z triple_fault 송금 (JOI19_remittance) C++14
100 / 100
382 ms 36596 KB
/* May 20 2020 */

#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <random>

#define ll long long

using namespace std;

int main(void) {
    ll n; scanf("%lld", &n);
    ll a[n], b[n];
    for (ll i = 0; i < n; ++i) scanf("%lld%lld", &a[i], &b[i]);

    ll nonzero_a = 0, nonzero_b = 0;
    for (ll i = 0; i < n; ++i) {
        nonzero_a |= (a[i] > 0);
        nonzero_b |= (b[i] > 0);
    }

    if (!nonzero_b) {
        if (nonzero_a) puts("No");
        else puts("Yes");
        return 0;
    }

    for (;;) {
        bool uhh = false;
        for (ll i = 0; i < n; ++i) {
            if (a[i] <= b[i]) continue;
            uhh = true;
            ll ts = (a[i] - b[i] + 1) / 2;
            a[(i + 1) % n] += ts; 
            a[i] -= (2 * ts);
        }

        if (!uhh) break;
    }

    for (ll i = 0; i < n; ++i) 
        if (a[i] != b[i]) {
            puts("No");
            return 0;
        }
    puts("Yes");
    return 0;
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:17:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     ll n; scanf("%lld", &n);
           ~~~~~^~~~~~~~~~~~
remittance.cpp:19:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (ll i = 0; i < n; ++i) scanf("%lld%lld", &a[i], &b[i]);
                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 4 ms 256 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 256 KB Output is correct
24 Correct 4 ms 256 KB Output is correct
25 Correct 4 ms 256 KB Output is correct
26 Correct 5 ms 256 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 4 ms 256 KB Output is correct
29 Correct 5 ms 256 KB Output is correct
30 Correct 4 ms 384 KB Output is correct
31 Correct 4 ms 256 KB Output is correct
32 Correct 4 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 4 ms 256 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 256 KB Output is correct
24 Correct 4 ms 256 KB Output is correct
25 Correct 4 ms 256 KB Output is correct
26 Correct 5 ms 256 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 4 ms 256 KB Output is correct
29 Correct 5 ms 256 KB Output is correct
30 Correct 4 ms 384 KB Output is correct
31 Correct 4 ms 256 KB Output is correct
32 Correct 4 ms 256 KB Output is correct
33 Correct 4 ms 256 KB Output is correct
34 Correct 4 ms 256 KB Output is correct
35 Correct 5 ms 256 KB Output is correct
36 Correct 4 ms 256 KB Output is correct
37 Correct 4 ms 256 KB Output is correct
38 Correct 4 ms 256 KB Output is correct
39 Correct 5 ms 256 KB Output is correct
40 Correct 4 ms 256 KB Output is correct
41 Correct 4 ms 256 KB Output is correct
42 Correct 4 ms 256 KB Output is correct
43 Correct 4 ms 256 KB Output is correct
44 Correct 4 ms 256 KB Output is correct
45 Correct 4 ms 256 KB Output is correct
46 Correct 4 ms 256 KB Output is correct
47 Correct 5 ms 256 KB Output is correct
48 Correct 5 ms 256 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 4 ms 384 KB Output is correct
51 Correct 4 ms 256 KB Output is correct
52 Correct 4 ms 256 KB Output is correct
53 Correct 5 ms 256 KB Output is correct
54 Correct 4 ms 256 KB Output is correct
55 Correct 4 ms 256 KB Output is correct
56 Correct 4 ms 256 KB Output is correct
57 Correct 5 ms 256 KB Output is correct
58 Correct 4 ms 256 KB Output is correct
59 Correct 4 ms 256 KB Output is correct
60 Correct 4 ms 256 KB Output is correct
61 Correct 4 ms 256 KB Output is correct
62 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 4 ms 256 KB Output is correct
16 Correct 4 ms 256 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 4 ms 256 KB Output is correct
19 Correct 4 ms 256 KB Output is correct
20 Correct 4 ms 256 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 256 KB Output is correct
23 Correct 5 ms 256 KB Output is correct
24 Correct 4 ms 256 KB Output is correct
25 Correct 4 ms 256 KB Output is correct
26 Correct 5 ms 256 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 4 ms 256 KB Output is correct
29 Correct 5 ms 256 KB Output is correct
30 Correct 4 ms 384 KB Output is correct
31 Correct 4 ms 256 KB Output is correct
32 Correct 4 ms 256 KB Output is correct
33 Correct 4 ms 256 KB Output is correct
34 Correct 4 ms 256 KB Output is correct
35 Correct 5 ms 256 KB Output is correct
36 Correct 4 ms 256 KB Output is correct
37 Correct 4 ms 256 KB Output is correct
38 Correct 4 ms 256 KB Output is correct
39 Correct 5 ms 256 KB Output is correct
40 Correct 4 ms 256 KB Output is correct
41 Correct 4 ms 256 KB Output is correct
42 Correct 4 ms 256 KB Output is correct
43 Correct 4 ms 256 KB Output is correct
44 Correct 4 ms 256 KB Output is correct
45 Correct 4 ms 256 KB Output is correct
46 Correct 4 ms 256 KB Output is correct
47 Correct 5 ms 256 KB Output is correct
48 Correct 5 ms 256 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 4 ms 384 KB Output is correct
51 Correct 4 ms 256 KB Output is correct
52 Correct 4 ms 256 KB Output is correct
53 Correct 5 ms 256 KB Output is correct
54 Correct 4 ms 256 KB Output is correct
55 Correct 4 ms 256 KB Output is correct
56 Correct 4 ms 256 KB Output is correct
57 Correct 5 ms 256 KB Output is correct
58 Correct 4 ms 256 KB Output is correct
59 Correct 4 ms 256 KB Output is correct
60 Correct 4 ms 256 KB Output is correct
61 Correct 4 ms 256 KB Output is correct
62 Correct 4 ms 384 KB Output is correct
63 Correct 382 ms 35296 KB Output is correct
64 Correct 203 ms 19808 KB Output is correct
65 Correct 375 ms 34808 KB Output is correct
66 Correct 194 ms 19904 KB Output is correct
67 Correct 212 ms 21216 KB Output is correct
68 Correct 236 ms 23564 KB Output is correct
69 Correct 379 ms 35436 KB Output is correct
70 Correct 198 ms 19960 KB Output is correct
71 Correct 208 ms 21240 KB Output is correct
72 Correct 243 ms 23672 KB Output is correct
73 Correct 379 ms 35496 KB Output is correct
74 Correct 193 ms 19960 KB Output is correct
75 Correct 214 ms 21240 KB Output is correct
76 Correct 233 ms 23544 KB Output is correct
77 Correct 376 ms 35320 KB Output is correct
78 Correct 284 ms 27596 KB Output is correct
79 Correct 268 ms 27516 KB Output is correct
80 Correct 283 ms 27568 KB Output is correct
81 Correct 282 ms 27516 KB Output is correct
82 Correct 166 ms 19832 KB Output is correct
83 Correct 170 ms 19808 KB Output is correct
84 Correct 189 ms 19960 KB Output is correct
85 Correct 351 ms 36596 KB Output is correct
86 Correct 341 ms 36344 KB Output is correct
87 Correct 230 ms 28664 KB Output is correct
88 Correct 238 ms 28732 KB Output is correct