# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
943763 | 2024-03-11T20:43:12 Z | tset | Coin Collecting (JOI19_ho_t4) | C++17 | 47 ms | 10400 KB |
#include<bits/stdc++.h> using namespace std; #define int long long signed main() { int nbLigs = 2,nbCols; scanf("%lld", &nbCols); vector<pair<int,int>> pts; for(int iPt =0; iPt<2*nbCols; iPt++) { int col, lig; scanf("%lld%lld", &col, &lig); pts.push_back({lig, col}); } int res = 0; vector<vector<int> > grille(2, vector<int>(nbCols, -1)); for(auto pt : pts) { int ligAct = pt.first; int colAct = pt.second; if(ligAct<1) { res += abs(1 - ligAct); ligAct = 1; } if(ligAct>2) { res += abs(2 - ligAct); ligAct = 2; } if(colAct<1) { res += abs(1 - colAct); colAct = 1; } if(colAct>nbCols) { res += abs(nbCols - colAct); colAct = nbCols; } ligAct--; colAct--; grille[ligAct][colAct]++; } for(int iC = 0; iC < nbCols; iC++) { if(iC >0) { grille[0][iC] += grille[0][iC-1]; grille[1][iC] += grille[1][iC-1]; } if(grille[0][iC] * grille[1][iC] < 0) { int transferable = max(grille[0][iC], grille[1][iC]); int needed = abs(min(grille[0][iC], grille[1][iC])); int transfered = min(transferable, needed); for(int iL=0; iL<2; iL++) { if(grille[iL][iC] < 0) grille[iL][iC] += transfered; else grille[iL][iC] -= transfered; } res += transfered; } res += abs(grille[0][iC]); res += abs(grille[1][iC]); } printf("%lld\n", res); }
Compilation message
# | 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 | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 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 | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 360 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 436 KB | Output is correct |
19 | Correct | 0 ms | 436 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 1 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 | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 344 KB | Output is correct |
30 | Correct | 1 ms | 436 KB | Output is correct |
31 | Correct | 0 ms | 344 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | 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 | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 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 | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 360 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 436 KB | Output is correct |
19 | Correct | 0 ms | 436 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 1 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 | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 344 KB | Output is correct |
30 | Correct | 1 ms | 436 KB | Output is correct |
31 | Correct | 0 ms | 344 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 1 ms | 344 KB | Output is correct |
35 | Correct | 1 ms | 500 KB | Output is correct |
36 | Correct | 1 ms | 348 KB | Output is correct |
37 | Correct | 1 ms | 344 KB | Output is correct |
38 | Correct | 1 ms | 448 KB | Output is correct |
39 | Correct | 1 ms | 448 KB | Output is correct |
40 | Correct | 1 ms | 344 KB | Output is correct |
41 | Correct | 1 ms | 348 KB | Output is correct |
42 | Correct | 1 ms | 348 KB | Output is correct |
43 | Correct | 1 ms | 348 KB | Output is correct |
44 | Correct | 1 ms | 344 KB | Output is correct |
45 | Correct | 1 ms | 348 KB | Output is correct |
46 | Correct | 1 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 | 344 KB | Output is correct |
50 | Correct | 1 ms | 348 KB | Output is correct |
51 | Correct | 1 ms | 348 KB | Output is correct |
52 | Correct | 1 ms | 348 KB | Output is correct |
53 | Correct | 1 ms | 344 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 | 344 KB | Output is correct |
57 | Correct | 1 ms | 344 KB | Output is correct |
58 | Correct | 1 ms | 348 KB | Output is correct |
59 | Correct | 1 ms | 604 KB | Output is correct |
60 | Correct | 1 ms | 344 KB | Output is correct |
61 | Correct | 1 ms | 348 KB | Output is correct |
62 | Correct | 1 ms | 348 KB | Output is correct |
63 | Correct | 1 ms | 348 KB | Output is correct |
64 | Correct | 1 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 | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 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 | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 360 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 436 KB | Output is correct |
19 | Correct | 0 ms | 436 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 1 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 | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 344 KB | Output is correct |
30 | Correct | 1 ms | 436 KB | Output is correct |
31 | Correct | 0 ms | 344 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 1 ms | 344 KB | Output is correct |
35 | Correct | 1 ms | 500 KB | Output is correct |
36 | Correct | 1 ms | 348 KB | Output is correct |
37 | Correct | 1 ms | 344 KB | Output is correct |
38 | Correct | 1 ms | 448 KB | Output is correct |
39 | Correct | 1 ms | 448 KB | Output is correct |
40 | Correct | 1 ms | 344 KB | Output is correct |
41 | Correct | 1 ms | 348 KB | Output is correct |
42 | Correct | 1 ms | 348 KB | Output is correct |
43 | Correct | 1 ms | 348 KB | Output is correct |
44 | Correct | 1 ms | 344 KB | Output is correct |
45 | Correct | 1 ms | 348 KB | Output is correct |
46 | Correct | 1 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 | 344 KB | Output is correct |
50 | Correct | 1 ms | 348 KB | Output is correct |
51 | Correct | 1 ms | 348 KB | Output is correct |
52 | Correct | 1 ms | 348 KB | Output is correct |
53 | Correct | 1 ms | 344 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 | 344 KB | Output is correct |
57 | Correct | 1 ms | 344 KB | Output is correct |
58 | Correct | 1 ms | 348 KB | Output is correct |
59 | Correct | 1 ms | 604 KB | Output is correct |
60 | Correct | 1 ms | 344 KB | Output is correct |
61 | Correct | 1 ms | 348 KB | Output is correct |
62 | Correct | 1 ms | 348 KB | Output is correct |
63 | Correct | 1 ms | 348 KB | Output is correct |
64 | Correct | 1 ms | 348 KB | Output is correct |
65 | Correct | 29 ms | 7356 KB | Output is correct |
66 | Correct | 39 ms | 10400 KB | Output is correct |
67 | Correct | 38 ms | 9832 KB | Output is correct |
68 | Correct | 34 ms | 8892 KB | Output is correct |
69 | Correct | 34 ms | 8888 KB | Output is correct |
70 | Correct | 37 ms | 9152 KB | Output is correct |
71 | Correct | 47 ms | 8920 KB | Output is correct |
72 | Correct | 42 ms | 8964 KB | Output is correct |
73 | Correct | 35 ms | 8900 KB | Output is correct |
74 | Correct | 34 ms | 9048 KB | Output is correct |
75 | Correct | 35 ms | 8896 KB | Output is correct |
76 | Correct | 36 ms | 9504 KB | Output is correct |
77 | Correct | 34 ms | 9000 KB | Output is correct |
78 | Correct | 34 ms | 9804 KB | Output is correct |
79 | Correct | 33 ms | 8892 KB | Output is correct |
80 | Correct | 43 ms | 8888 KB | Output is correct |
81 | Correct | 33 ms | 9416 KB | Output is correct |
82 | Correct | 34 ms | 9216 KB | Output is correct |
83 | Correct | 41 ms | 9404 KB | Output is correct |
84 | Correct | 44 ms | 9240 KB | Output is correct |
85 | Correct | 33 ms | 8892 KB | Output is correct |
86 | Correct | 38 ms | 9032 KB | Output is correct |
87 | Correct | 34 ms | 9064 KB | Output is correct |
88 | Correct | 34 ms | 9660 KB | Output is correct |
89 | Correct | 34 ms | 9308 KB | Output is correct |
90 | Correct | 34 ms | 8972 KB | Output is correct |
91 | Correct | 34 ms | 9404 KB | Output is correct |
92 | Correct | 35 ms | 9152 KB | Output is correct |
93 | Correct | 34 ms | 8960 KB | Output is correct |
94 | Correct | 32 ms | 8892 KB | Output is correct |
95 | Correct | 32 ms | 8892 KB | Output is correct |
96 | Correct | 34 ms | 9660 KB | Output is correct |
97 | Correct | 33 ms | 9160 KB | Output is correct |
98 | Correct | 34 ms | 8892 KB | Output is correct |
99 | Correct | 40 ms | 8932 KB | Output is correct |
100 | Correct | 34 ms | 9672 KB | Output is correct |
101 | Correct | 33 ms | 9148 KB | Output is correct |
102 | Correct | 34 ms | 9144 KB | Output is correct |
103 | Correct | 33 ms | 9404 KB | Output is correct |