Submission #227249

# Submission time Handle Problem Language Result Execution time Memory
227249 2020-04-26T15:39:19 Z alexandra_udristoiu Remittance (JOI19_remittance) C++14
100 / 100
383 ms 28908 KB
#include<iostream>
#include<cstdio>
#define DIM 1000005
using namespace std;
int n, i, ok, x;
int a[DIM], b[DIM];
long long sum, sum2;
int nxt(int i){
    if(i == n){
        return 1;
    }
    return i + 1;
}
int main(){
    scanf("%d", &n);
    ok = 1;
    for(i = 1; i <= n; i++){
        scanf("%d%d", &a[i], &b[i]);
        if(a[i] != 0){
            ok = 0;
        }
        sum2 += b[i];
    }
    if(sum2 == 0 && ok == 0){
        cout<<"No";
        return 0;
    }
    do{
        ok = 1;
        for(i = 1; i <= n; i++){
            if(a[i] != b[i]){
                ok = 0;
                if(a[i] > b[i]){
                    x = (a[i] - b[i]) / 2 + (a[i] - b[i]) % 2;
                    a[ nxt(i) ] += x;
                    a[i] -= 2 * x;
                }
            }
        }
        sum = 0;
        for(i = 1; i <= n; i++){
            sum += a[i];
        }
        if(sum < sum2){
            break;
        }
    }while(ok == 0);

    if(ok == 1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
remittance.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &a[i], &b[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 4 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 256 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 4 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 256 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 5 ms 512 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 4 ms 384 KB Output is correct
35 Correct 4 ms 384 KB Output is correct
36 Correct 4 ms 384 KB Output is correct
37 Correct 5 ms 512 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 5 ms 384 KB Output is correct
40 Correct 4 ms 384 KB Output is correct
41 Correct 4 ms 384 KB Output is correct
42 Correct 5 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 4 ms 384 KB Output is correct
53 Correct 4 ms 384 KB Output is correct
54 Correct 4 ms 384 KB Output is correct
55 Correct 5 ms 384 KB Output is correct
56 Correct 4 ms 384 KB Output is correct
57 Correct 5 ms 384 KB Output is correct
58 Correct 5 ms 384 KB Output is correct
59 Correct 4 ms 256 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 5 ms 384 KB Output is correct
62 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 4 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 256 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 5 ms 512 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 4 ms 384 KB Output is correct
35 Correct 4 ms 384 KB Output is correct
36 Correct 4 ms 384 KB Output is correct
37 Correct 5 ms 512 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 5 ms 384 KB Output is correct
40 Correct 4 ms 384 KB Output is correct
41 Correct 4 ms 384 KB Output is correct
42 Correct 5 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 4 ms 384 KB Output is correct
53 Correct 4 ms 384 KB Output is correct
54 Correct 4 ms 384 KB Output is correct
55 Correct 5 ms 384 KB Output is correct
56 Correct 4 ms 384 KB Output is correct
57 Correct 5 ms 384 KB Output is correct
58 Correct 5 ms 384 KB Output is correct
59 Correct 4 ms 256 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 5 ms 384 KB Output is correct
62 Correct 5 ms 384 KB Output is correct
63 Correct 373 ms 10308 KB Output is correct
64 Correct 193 ms 12024 KB Output is correct
65 Correct 383 ms 27176 KB Output is correct
66 Correct 190 ms 12024 KB Output is correct
67 Correct 206 ms 13432 KB Output is correct
68 Correct 232 ms 15864 KB Output is correct
69 Correct 374 ms 27512 KB Output is correct
70 Correct 189 ms 12024 KB Output is correct
71 Correct 204 ms 13496 KB Output is correct
72 Correct 228 ms 15864 KB Output is correct
73 Correct 372 ms 27512 KB Output is correct
74 Correct 182 ms 12024 KB Output is correct
75 Correct 207 ms 13432 KB Output is correct
76 Correct 230 ms 15864 KB Output is correct
77 Correct 373 ms 27516 KB Output is correct
78 Correct 267 ms 19932 KB Output is correct
79 Correct 263 ms 19744 KB Output is correct
80 Correct 277 ms 19832 KB Output is correct
81 Correct 274 ms 19832 KB Output is correct
82 Correct 160 ms 12024 KB Output is correct
83 Correct 158 ms 12024 KB Output is correct
84 Correct 176 ms 12144 KB Output is correct
85 Correct 340 ms 28536 KB Output is correct
86 Correct 335 ms 28908 KB Output is correct
87 Correct 227 ms 20856 KB Output is correct
88 Correct 225 ms 20832 KB Output is correct