Submission #1010720

# Submission time Handle Problem Language Result Execution time Memory
1010720 2024-06-29T09:59:49 Z danikoynov Remittance (JOI19_remittance) C++14
100 / 100
541 ms 36436 KB
#include<bits/stdc++.h>
#define endl '\n'

typedef long long ll;


const int MAX_N = 1e6 + 10;

int n;
ll a[MAX_N], b[MAX_N];
void solve()
{
    //std::cout << "Yes" << endl;
    //exit(0);
    std::cin >> n;
    for (int i = 1; i <= n; i ++)
        std::cin >> a[i] >> b[i];    
    
    while(true)
    {
        bool done = true;
        for (int i = 1; i <= n; i ++)
        {
            int nxt = i + 1;
            if (i == n)
                nxt = 1;

            ll left = a[i] - b[i];
            if (left < 0)
                left = 0;

            if (left % 2 == 1 && b[i] > 0)
                left ++;
            left /= 2;

            a[i] -= left * 2;
            a[nxt] += left;
            if (left != 0)
                done = false;
        }

        if (done)
            break;
    }

    bool fine = true;
    for (int i = 1; i <= n; i ++)
        if (a[i] != b[i])
            fine = false;
    
    if (fine)
        std::cout << "Yes" << endl;
    else
        std::cout << "No" << endl;
}

void speed()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
}

int main()
{
    solve();
    return 0;
}
/**
2 
0 2
4 0
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 0 ms 444 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 436 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 448 KB Output is correct
29 Correct 0 ms 604 KB Output is correct
30 Correct 1 ms 448 KB Output is correct
31 Correct 0 ms 448 KB Output is correct
32 Correct 0 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 0 ms 444 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 436 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 448 KB Output is correct
29 Correct 0 ms 604 KB Output is correct
30 Correct 1 ms 448 KB Output is correct
31 Correct 0 ms 448 KB Output is correct
32 Correct 0 ms 444 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 444 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 444 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 604 KB Output is correct
42 Correct 0 ms 440 KB Output is correct
43 Correct 0 ms 440 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 444 KB Output is correct
47 Correct 0 ms 444 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 352 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 1 ms 344 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 0 ms 348 KB Output is correct
56 Correct 0 ms 348 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 0 ms 444 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 436 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 448 KB Output is correct
29 Correct 0 ms 604 KB Output is correct
30 Correct 1 ms 448 KB Output is correct
31 Correct 0 ms 448 KB Output is correct
32 Correct 0 ms 444 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 444 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 444 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 604 KB Output is correct
42 Correct 0 ms 440 KB Output is correct
43 Correct 0 ms 440 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 444 KB Output is correct
47 Correct 0 ms 444 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 352 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 1 ms 344 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 0 ms 348 KB Output is correct
56 Correct 0 ms 348 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 487 ms 35284 KB Output is correct
64 Correct 172 ms 19796 KB Output is correct
65 Correct 541 ms 34896 KB Output is correct
66 Correct 177 ms 19948 KB Output is correct
67 Correct 221 ms 21328 KB Output is correct
68 Correct 269 ms 23644 KB Output is correct
69 Correct 520 ms 35400 KB Output is correct
70 Correct 168 ms 19796 KB Output is correct
71 Correct 197 ms 21256 KB Output is correct
72 Correct 306 ms 23636 KB Output is correct
73 Correct 486 ms 35412 KB Output is correct
74 Correct 175 ms 19976 KB Output is correct
75 Correct 207 ms 21212 KB Output is correct
76 Correct 242 ms 23652 KB Output is correct
77 Correct 464 ms 35404 KB Output is correct
78 Correct 326 ms 27472 KB Output is correct
79 Correct 318 ms 27476 KB Output is correct
80 Correct 322 ms 27476 KB Output is correct
81 Correct 304 ms 27472 KB Output is correct
82 Correct 150 ms 19948 KB Output is correct
83 Correct 153 ms 19796 KB Output is correct
84 Correct 178 ms 19800 KB Output is correct
85 Correct 491 ms 36436 KB Output is correct
86 Correct 472 ms 36232 KB Output is correct
87 Correct 317 ms 28692 KB Output is correct
88 Correct 341 ms 28608 KB Output is correct