Submission #904827

# Submission time Handle Problem Language Result Execution time Memory
904827 2024-01-12T09:18:56 Z vjudge1 Remittance (JOI19_remittance) C++17
100 / 100
247 ms 36468 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ld long double
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
#define fast ios::sync_with_stdio(false), cin.tie(NULL)

const int MAXN = 2e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int SQ = 350;
const int LG = 23;

signed main()
{
    fast;
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    bool f1 = 0, f2 = 0;
    for (int i = 0; i < n; i++)
        if (a[i])
            f1 = 1;
    for (int i = 0; i < n; i++)
        if (b[i])
            f2 = 1;
    if (!f1 && !f2)
        return cout << "Yes", 0;
    if (f1 ^ f2)
        return cout << "No", 0;
    while (true)
    {
        bool good = 1;
        for (int i = 0; i < n; i++)
            if (a[i] > b[i])
                good = 0;
        if (good)
            break;
        for (int i = 0; i < n; i++)
            if (a[i] > b[i])
            {
                int x = (a[i] - b[i] + 1) >> 1;
                a[i] -= x * 2;
                a[(i + 1) % n] += x;
            }
    }
    bool good = 1;
    for (int i = 0; i < n; i++)
        if (a[i] != b[i])
            good = 0;
    if (good)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 360 KB Output is correct
29 Correct 1 ms 464 KB Output is correct
30 Correct 1 ms 616 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 360 KB Output is correct
29 Correct 1 ms 464 KB Output is correct
30 Correct 1 ms 616 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 360 KB Output is correct
33 Correct 1 ms 360 KB Output is correct
34 Correct 1 ms 360 KB Output is correct
35 Correct 1 ms 360 KB Output is correct
36 Correct 0 ms 360 KB Output is correct
37 Correct 1 ms 360 KB Output is correct
38 Correct 0 ms 360 KB Output is correct
39 Correct 1 ms 360 KB Output is correct
40 Correct 0 ms 360 KB Output is correct
41 Correct 1 ms 360 KB Output is correct
42 Correct 1 ms 360 KB Output is correct
43 Correct 1 ms 616 KB Output is correct
44 Correct 1 ms 360 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 456 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 1 ms 500 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 1 ms 348 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 1 ms 604 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 360 KB Output is correct
29 Correct 1 ms 464 KB Output is correct
30 Correct 1 ms 616 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 360 KB Output is correct
33 Correct 1 ms 360 KB Output is correct
34 Correct 1 ms 360 KB Output is correct
35 Correct 1 ms 360 KB Output is correct
36 Correct 0 ms 360 KB Output is correct
37 Correct 1 ms 360 KB Output is correct
38 Correct 0 ms 360 KB Output is correct
39 Correct 1 ms 360 KB Output is correct
40 Correct 0 ms 360 KB Output is correct
41 Correct 1 ms 360 KB Output is correct
42 Correct 1 ms 360 KB Output is correct
43 Correct 1 ms 616 KB Output is correct
44 Correct 1 ms 360 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 456 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 1 ms 500 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 1 ms 348 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 1 ms 604 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 181 ms 35320 KB Output is correct
64 Correct 97 ms 19796 KB Output is correct
65 Correct 177 ms 34924 KB Output is correct
66 Correct 104 ms 19908 KB Output is correct
67 Correct 112 ms 21188 KB Output is correct
68 Correct 126 ms 23632 KB Output is correct
69 Correct 169 ms 35412 KB Output is correct
70 Correct 103 ms 19796 KB Output is correct
71 Correct 108 ms 21392 KB Output is correct
72 Correct 126 ms 23632 KB Output is correct
73 Correct 171 ms 35408 KB Output is correct
74 Correct 99 ms 19908 KB Output is correct
75 Correct 112 ms 21320 KB Output is correct
76 Correct 114 ms 23632 KB Output is correct
77 Correct 173 ms 35424 KB Output is correct
78 Correct 135 ms 27612 KB Output is correct
79 Correct 138 ms 27476 KB Output is correct
80 Correct 193 ms 27516 KB Output is correct
81 Correct 179 ms 27724 KB Output is correct
82 Correct 106 ms 19784 KB Output is correct
83 Correct 79 ms 19796 KB Output is correct
84 Correct 83 ms 19916 KB Output is correct
85 Correct 247 ms 36468 KB Output is correct
86 Correct 196 ms 36436 KB Output is correct
87 Correct 189 ms 28604 KB Output is correct
88 Correct 143 ms 28748 KB Output is correct