# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
770264 | 2023-07-01T04:09:18 Z | Amylopectin | Team Contest (JOI22_team) | C++14 | 99 ms | 8936 KB |
#include <stdio.h> #include <iostream> #include <algorithm> using namespace std; const int mxn = 1e6 + 10; // const int mxn = 30; struct we { int val,idx; }; bool cmp(const struct we &l,const struct we &r) { return l.val > r.val; } struct we ta[3][mxn],yy[mxn],zz[mxn]; int u[mxn] = {},atc[mxn] = {}; int main() { int i,j,n,m,cn,cx,cy,cz,ncc[3] = {},of,ru[3] = {},ans = 0; scanf("%d",&n); for(i=0; i<n; i++) { scanf("%d %d %d",&cx,&cy,&cz); ta[0][i] = {cx,i}; ta[1][i] = {cy,i}; ta[2][i] = {cz,i}; } for(i=0 ;i<3; i++) sort(ta[i],ta[i]+n,cmp); // sort(yy,yy+n,cmp); // sort(zz,zz+n,cmp); while(1) { of = 0; for(i=0; i<3; i++) { if(ncc[i] == 0) { for(j=ru[i]; ta[i][j].val== ta[i][ru[i]].val && j < n; j++) { cn = ta[i][j].idx; if(u[cn] == 0) { u[cn] = 1; atc[cn] = i; ncc[i] ++; } else if(u[cn] == 1) { u[cn] = 2; ncc[atc[cn]] --; } } ru[i] = j; if(j == n) { ans = -1; break; } of = 1; break; } } if(ans == -1) { break; } if(of == 0) { ans = 0; for(i=0; i<3; i++) { ans += ta[i][ru[i]-1].val; } break; } } printf("%d\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 2 ms | 340 KB | Output is correct |
27 | Correct | 3 ms | 468 KB | Output is correct |
28 | Correct | 3 ms | 468 KB | Output is correct |
29 | Correct | 3 ms | 468 KB | Output is correct |
30 | Correct | 2 ms | 340 KB | Output is correct |
31 | Correct | 3 ms | 468 KB | Output is correct |
32 | Correct | 2 ms | 444 KB | Output is correct |
33 | Correct | 2 ms | 468 KB | Output is correct |
34 | Correct | 2 ms | 576 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 1 ms | 340 KB | Output is correct |
37 | Correct | 2 ms | 468 KB | Output is correct |
38 | Correct | 2 ms | 468 KB | Output is correct |
39 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 50 ms | 4984 KB | Output is correct |
12 | Correct | 33 ms | 4044 KB | Output is correct |
13 | Correct | 34 ms | 4892 KB | Output is correct |
14 | Correct | 45 ms | 5836 KB | Output is correct |
15 | Correct | 42 ms | 5868 KB | Output is correct |
16 | Correct | 42 ms | 5956 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 50 ms | 4984 KB | Output is correct |
12 | Correct | 33 ms | 4044 KB | Output is correct |
13 | Correct | 34 ms | 4892 KB | Output is correct |
14 | Correct | 45 ms | 5836 KB | Output is correct |
15 | Correct | 42 ms | 5868 KB | Output is correct |
16 | Correct | 42 ms | 5956 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 51 ms | 6104 KB | Output is correct |
23 | Correct | 45 ms | 5812 KB | Output is correct |
24 | Correct | 36 ms | 4428 KB | Output is correct |
25 | Correct | 49 ms | 6124 KB | Output is correct |
26 | Correct | 50 ms | 5920 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 50 ms | 4984 KB | Output is correct |
12 | Correct | 33 ms | 4044 KB | Output is correct |
13 | Correct | 34 ms | 4892 KB | Output is correct |
14 | Correct | 45 ms | 5836 KB | Output is correct |
15 | Correct | 42 ms | 5868 KB | Output is correct |
16 | Correct | 42 ms | 5956 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 51 ms | 6104 KB | Output is correct |
23 | Correct | 45 ms | 5812 KB | Output is correct |
24 | Correct | 36 ms | 4428 KB | Output is correct |
25 | Correct | 49 ms | 6124 KB | Output is correct |
26 | Correct | 50 ms | 5920 KB | Output is correct |
27 | Correct | 1 ms | 400 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 308 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 2 ms | 468 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 316 KB | Output is correct |
34 | Correct | 54 ms | 6208 KB | Output is correct |
35 | Correct | 57 ms | 5936 KB | Output is correct |
36 | Correct | 57 ms | 6508 KB | Output is correct |
37 | Correct | 57 ms | 6624 KB | Output is correct |
38 | Correct | 45 ms | 6532 KB | Output is correct |
39 | Correct | 32 ms | 4056 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 50 ms | 4984 KB | Output is correct |
12 | Correct | 33 ms | 4044 KB | Output is correct |
13 | Correct | 34 ms | 4892 KB | Output is correct |
14 | Correct | 45 ms | 5836 KB | Output is correct |
15 | Correct | 42 ms | 5868 KB | Output is correct |
16 | Correct | 42 ms | 5956 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 51 ms | 6104 KB | Output is correct |
23 | Correct | 45 ms | 5812 KB | Output is correct |
24 | Correct | 36 ms | 4428 KB | Output is correct |
25 | Correct | 49 ms | 6124 KB | Output is correct |
26 | Correct | 50 ms | 5920 KB | Output is correct |
27 | Correct | 1 ms | 400 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 308 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 2 ms | 468 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 316 KB | Output is correct |
34 | Correct | 54 ms | 6208 KB | Output is correct |
35 | Correct | 57 ms | 5936 KB | Output is correct |
36 | Correct | 57 ms | 6508 KB | Output is correct |
37 | Correct | 57 ms | 6624 KB | Output is correct |
38 | Correct | 45 ms | 6532 KB | Output is correct |
39 | Correct | 32 ms | 4056 KB | Output is correct |
40 | Correct | 2 ms | 340 KB | Output is correct |
41 | Correct | 2 ms | 468 KB | Output is correct |
42 | Correct | 2 ms | 468 KB | Output is correct |
43 | Correct | 2 ms | 400 KB | Output is correct |
44 | Correct | 64 ms | 6420 KB | Output is correct |
45 | Correct | 65 ms | 7096 KB | Output is correct |
46 | Correct | 75 ms | 6980 KB | Output is correct |
47 | Correct | 71 ms | 7156 KB | Output is correct |
48 | Correct | 49 ms | 6912 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 0 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 2 ms | 340 KB | Output is correct |
27 | Correct | 3 ms | 468 KB | Output is correct |
28 | Correct | 3 ms | 468 KB | Output is correct |
29 | Correct | 3 ms | 468 KB | Output is correct |
30 | Correct | 2 ms | 340 KB | Output is correct |
31 | Correct | 3 ms | 468 KB | Output is correct |
32 | Correct | 2 ms | 444 KB | Output is correct |
33 | Correct | 2 ms | 468 KB | Output is correct |
34 | Correct | 2 ms | 576 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 1 ms | 340 KB | Output is correct |
37 | Correct | 2 ms | 468 KB | Output is correct |
38 | Correct | 2 ms | 468 KB | Output is correct |
39 | Correct | 1 ms | 340 KB | Output is correct |
40 | Correct | 1 ms | 340 KB | Output is correct |
41 | Correct | 0 ms | 340 KB | Output is correct |
42 | Correct | 1 ms | 384 KB | Output is correct |
43 | Correct | 0 ms | 340 KB | Output is correct |
44 | Correct | 0 ms | 340 KB | Output is correct |
45 | Correct | 0 ms | 340 KB | Output is correct |
46 | Correct | 0 ms | 340 KB | Output is correct |
47 | Correct | 0 ms | 340 KB | Output is correct |
48 | Correct | 0 ms | 212 KB | Output is correct |
49 | Correct | 0 ms | 212 KB | Output is correct |
50 | Correct | 50 ms | 4984 KB | Output is correct |
51 | Correct | 33 ms | 4044 KB | Output is correct |
52 | Correct | 34 ms | 4892 KB | Output is correct |
53 | Correct | 45 ms | 5836 KB | Output is correct |
54 | Correct | 42 ms | 5868 KB | Output is correct |
55 | Correct | 42 ms | 5956 KB | Output is correct |
56 | Correct | 1 ms | 340 KB | Output is correct |
57 | Correct | 1 ms | 340 KB | Output is correct |
58 | Correct | 1 ms | 340 KB | Output is correct |
59 | Correct | 1 ms | 340 KB | Output is correct |
60 | Correct | 1 ms | 340 KB | Output is correct |
61 | Correct | 51 ms | 6104 KB | Output is correct |
62 | Correct | 45 ms | 5812 KB | Output is correct |
63 | Correct | 36 ms | 4428 KB | Output is correct |
64 | Correct | 49 ms | 6124 KB | Output is correct |
65 | Correct | 50 ms | 5920 KB | Output is correct |
66 | Correct | 1 ms | 400 KB | Output is correct |
67 | Correct | 1 ms | 340 KB | Output is correct |
68 | Correct | 1 ms | 308 KB | Output is correct |
69 | Correct | 1 ms | 340 KB | Output is correct |
70 | Correct | 2 ms | 468 KB | Output is correct |
71 | Correct | 1 ms | 340 KB | Output is correct |
72 | Correct | 1 ms | 316 KB | Output is correct |
73 | Correct | 54 ms | 6208 KB | Output is correct |
74 | Correct | 57 ms | 5936 KB | Output is correct |
75 | Correct | 57 ms | 6508 KB | Output is correct |
76 | Correct | 57 ms | 6624 KB | Output is correct |
77 | Correct | 45 ms | 6532 KB | Output is correct |
78 | Correct | 32 ms | 4056 KB | Output is correct |
79 | Correct | 2 ms | 340 KB | Output is correct |
80 | Correct | 2 ms | 468 KB | Output is correct |
81 | Correct | 2 ms | 468 KB | Output is correct |
82 | Correct | 2 ms | 400 KB | Output is correct |
83 | Correct | 64 ms | 6420 KB | Output is correct |
84 | Correct | 65 ms | 7096 KB | Output is correct |
85 | Correct | 75 ms | 6980 KB | Output is correct |
86 | Correct | 71 ms | 7156 KB | Output is correct |
87 | Correct | 49 ms | 6912 KB | Output is correct |
88 | Correct | 79 ms | 7740 KB | Output is correct |
89 | Correct | 86 ms | 8892 KB | Output is correct |
90 | Correct | 86 ms | 8856 KB | Output is correct |
91 | Correct | 99 ms | 8864 KB | Output is correct |
92 | Correct | 76 ms | 7372 KB | Output is correct |
93 | Correct | 79 ms | 7756 KB | Output is correct |
94 | Correct | 91 ms | 7556 KB | Output is correct |
95 | Correct | 56 ms | 8700 KB | Output is correct |
96 | Correct | 80 ms | 8920 KB | Output is correct |
97 | Correct | 55 ms | 8936 KB | Output is correct |
98 | Correct | 55 ms | 6364 KB | Output is correct |
99 | Correct | 54 ms | 7444 KB | Output is correct |