Submission #200527

# Submission time Handle Problem Language Result Execution time Memory
200527 2020-02-07T06:17:52 Z HellAngel Remittance (JOI19_remittance) C++14
100 / 100
347 ms 36488 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1000007;
int a[maxn], b[maxn], n;
void AnsNo()
{
    cout << "No";
    exit(0);
}
void AnsYes()
{
    cout << "Yes";
    exit(0);
}

void Change(int pos, int val)
{
    a[pos] -= 2 * val;
    pos++;
    if(pos == n) pos = 0;
    a[pos] += val;
}

int32_t main()
{
    auto start = chrono::steady_clock::now();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    while(true)
    {
        bool ok = false;
        for(int i = 0; i < n; i++)
        {
            if(a[i] > b[i])
            {
                int nxt = a[i] - b[i] >> 1;
                if(nxt == 0 && a[i] > 1) Change(i, 1), ok = 1;
                if(nxt > 0) Change(i, nxt), ok = 1;
            }
        }
        if(!ok) break;
    }
    for(int i = 0; i < n; i++) if(a[i] != b[i]) AnsNo();
    AnsYes();
    auto finish = chrono::steady_clock::now();
    cerr << '\n'<< chrono::duration_cast<chrono::milliseconds>(finish - start).count();
}

Compilation message

remittance.cpp: In function 'int32_t main()':
remittance.cpp:40:32: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
                 int nxt = a[i] - b[i] >> 1;
                           ~~~~~^~~~~~
remittance.cpp:30:39: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
                                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 380 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 6 ms 380 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 380 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 7 ms 248 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 380 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 6 ms 380 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 380 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 7 ms 248 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 5 ms 380 KB Output is correct
37 Correct 5 ms 376 KB Output is correct
38 Correct 5 ms 376 KB Output is correct
39 Correct 5 ms 376 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 5 ms 376 KB Output is correct
42 Correct 5 ms 376 KB Output is correct
43 Correct 5 ms 376 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 5 ms 388 KB Output is correct
46 Correct 5 ms 376 KB Output is correct
47 Correct 5 ms 376 KB Output is correct
48 Correct 5 ms 388 KB Output is correct
49 Correct 5 ms 404 KB Output is correct
50 Correct 5 ms 376 KB Output is correct
51 Correct 5 ms 384 KB Output is correct
52 Correct 5 ms 384 KB Output is correct
53 Correct 6 ms 376 KB Output is correct
54 Correct 5 ms 376 KB Output is correct
55 Correct 5 ms 376 KB Output is correct
56 Correct 5 ms 376 KB Output is correct
57 Correct 5 ms 392 KB Output is correct
58 Correct 5 ms 376 KB Output is correct
59 Correct 5 ms 376 KB Output is correct
60 Correct 5 ms 376 KB Output is correct
61 Correct 5 ms 376 KB Output is correct
62 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 380 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 6 ms 380 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 380 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 7 ms 248 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 5 ms 376 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 5 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 5 ms 380 KB Output is correct
37 Correct 5 ms 376 KB Output is correct
38 Correct 5 ms 376 KB Output is correct
39 Correct 5 ms 376 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 5 ms 376 KB Output is correct
42 Correct 5 ms 376 KB Output is correct
43 Correct 5 ms 376 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 5 ms 388 KB Output is correct
46 Correct 5 ms 376 KB Output is correct
47 Correct 5 ms 376 KB Output is correct
48 Correct 5 ms 388 KB Output is correct
49 Correct 5 ms 404 KB Output is correct
50 Correct 5 ms 376 KB Output is correct
51 Correct 5 ms 384 KB Output is correct
52 Correct 5 ms 384 KB Output is correct
53 Correct 6 ms 376 KB Output is correct
54 Correct 5 ms 376 KB Output is correct
55 Correct 5 ms 376 KB Output is correct
56 Correct 5 ms 376 KB Output is correct
57 Correct 5 ms 392 KB Output is correct
58 Correct 5 ms 376 KB Output is correct
59 Correct 5 ms 376 KB Output is correct
60 Correct 5 ms 376 KB Output is correct
61 Correct 5 ms 376 KB Output is correct
62 Correct 5 ms 376 KB Output is correct
63 Correct 318 ms 35320 KB Output is correct
64 Correct 141 ms 19964 KB Output is correct
65 Correct 310 ms 35020 KB Output is correct
66 Correct 160 ms 19960 KB Output is correct
67 Correct 167 ms 21372 KB Output is correct
68 Correct 162 ms 23672 KB Output is correct
69 Correct 302 ms 35448 KB Output is correct
70 Correct 140 ms 19960 KB Output is correct
71 Correct 157 ms 21496 KB Output is correct
72 Correct 167 ms 23672 KB Output is correct
73 Correct 304 ms 35532 KB Output is correct
74 Correct 135 ms 19960 KB Output is correct
75 Correct 143 ms 21368 KB Output is correct
76 Correct 163 ms 23672 KB Output is correct
77 Correct 326 ms 35524 KB Output is correct
78 Correct 207 ms 27640 KB Output is correct
79 Correct 211 ms 27640 KB Output is correct
80 Correct 217 ms 27604 KB Output is correct
81 Correct 233 ms 27808 KB Output is correct
82 Correct 120 ms 19960 KB Output is correct
83 Correct 136 ms 19960 KB Output is correct
84 Correct 141 ms 19960 KB Output is correct
85 Correct 347 ms 36480 KB Output is correct
86 Correct 338 ms 36488 KB Output is correct
87 Correct 245 ms 28792 KB Output is correct
88 Correct 233 ms 28684 KB Output is correct