# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
918637 | 2024-01-30T08:11:27 Z | _VIBE | Team Contest (JOI22_team) | C++17 | 366 ms | 32340 KB |
#include "bits/stdc++.h" using namespace std; #define int long long #define endl '\n' void Excuse_Me(int TC) { int n; cin>>n; set<pair<int,int>> s[3]; int g[n][3]; for(int i=0;i<n;i++){ for(int j=0;j<3;j++){ cin>>g[i][j]; s[j].insert({g[i][j],i}); } } bool ok=true; while(ok and (!s[0].empty()) and (!s[1].empty()) and (!s[2].empty())){ ok=false; for(int i=0;i<3;i++){ if(ok) break; pair<int,int> p=*s[i].rbegin(); for(int j=0;j<3;j++){ if(i==j) continue; if(g[p.second][j]>=((*s[j].rbegin()).first)){ ok=true; s[i].erase(p); s[j].erase({g[p.second][j],p.second}); break; } } } } int ans=0; bool poss=true; for(int i=0;i<3;i++){ if(s[i].empty()) poss=false; else ans+=((*s[i].rbegin()).first); } if(!poss) cout<<-1; else cout<<ans; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); freopen("error.txt","w",stderr); int Tc=1; // cin>>Tc; for(int tc=1;tc<=Tc;tc++) { Excuse_Me(tc); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 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 | 1 ms | 344 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 | 0 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 | 344 KB | Output is correct |
17 | Correct | 1 ms | 344 KB | Output is correct |
18 | Correct | 1 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 | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 600 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 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 | 1 ms | 344 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 | 0 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 | 344 KB | Output is correct |
17 | Correct | 1 ms | 344 KB | Output is correct |
18 | Correct | 1 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 | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 600 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 4 ms | 1112 KB | Output is correct |
27 | Correct | 4 ms | 1112 KB | Output is correct |
28 | Correct | 4 ms | 1116 KB | Output is correct |
29 | Correct | 4 ms | 1116 KB | Output is correct |
30 | Correct | 3 ms | 860 KB | Output is correct |
31 | Correct | 3 ms | 1116 KB | Output is correct |
32 | Correct | 4 ms | 1116 KB | Output is correct |
33 | Correct | 4 ms | 1116 KB | Output is correct |
34 | Correct | 3 ms | 1116 KB | Output is correct |
35 | Correct | 1 ms | 604 KB | Output is correct |
36 | Correct | 1 ms | 604 KB | Output is correct |
37 | Correct | 3 ms | 1116 KB | Output is correct |
38 | Correct | 3 ms | 1116 KB | Output is correct |
39 | Correct | 1 ms | 860 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 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 | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 161 ms | 32084 KB | Output is correct |
12 | Correct | 104 ms | 21328 KB | Output is correct |
13 | Correct | 110 ms | 26452 KB | Output is correct |
14 | Correct | 201 ms | 32336 KB | Output is correct |
15 | Correct | 150 ms | 32100 KB | Output is correct |
16 | Correct | 144 ms | 32080 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 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 | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 161 ms | 32084 KB | Output is correct |
12 | Correct | 104 ms | 21328 KB | Output is correct |
13 | Correct | 110 ms | 26452 KB | Output is correct |
14 | Correct | 201 ms | 32336 KB | Output is correct |
15 | Correct | 150 ms | 32100 KB | Output is correct |
16 | Correct | 144 ms | 32080 KB | Output is correct |
17 | Correct | 1 ms | 348 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 | 1 ms | 860 KB | Output is correct |
22 | Correct | 178 ms | 31992 KB | Output is correct |
23 | Correct | 173 ms | 31312 KB | Output is correct |
24 | Correct | 131 ms | 23380 KB | Output is correct |
25 | Correct | 212 ms | 32080 KB | Output is correct |
26 | Correct | 154 ms | 32084 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 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 | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 161 ms | 32084 KB | Output is correct |
12 | Correct | 104 ms | 21328 KB | Output is correct |
13 | Correct | 110 ms | 26452 KB | Output is correct |
14 | Correct | 201 ms | 32336 KB | Output is correct |
15 | Correct | 150 ms | 32100 KB | Output is correct |
16 | Correct | 144 ms | 32080 KB | Output is correct |
17 | Correct | 1 ms | 348 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 | 1 ms | 860 KB | Output is correct |
22 | Correct | 178 ms | 31992 KB | Output is correct |
23 | Correct | 173 ms | 31312 KB | Output is correct |
24 | Correct | 131 ms | 23380 KB | Output is correct |
25 | Correct | 212 ms | 32080 KB | Output is correct |
26 | Correct | 154 ms | 32084 KB | Output is correct |
27 | Correct | 1 ms | 344 KB | Output is correct |
28 | Correct | 0 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 4 ms | 1116 KB | Output is correct |
32 | Correct | 1 ms | 600 KB | Output is correct |
33 | Correct | 1 ms | 604 KB | Output is correct |
34 | Correct | 266 ms | 30388 KB | Output is correct |
35 | Correct | 243 ms | 29012 KB | Output is correct |
36 | Correct | 273 ms | 32124 KB | Output is correct |
37 | Correct | 283 ms | 31768 KB | Output is correct |
38 | Correct | 171 ms | 31316 KB | Output is correct |
39 | Correct | 93 ms | 19284 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 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 | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 161 ms | 32084 KB | Output is correct |
12 | Correct | 104 ms | 21328 KB | Output is correct |
13 | Correct | 110 ms | 26452 KB | Output is correct |
14 | Correct | 201 ms | 32336 KB | Output is correct |
15 | Correct | 150 ms | 32100 KB | Output is correct |
16 | Correct | 144 ms | 32080 KB | Output is correct |
17 | Correct | 1 ms | 348 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 | 1 ms | 860 KB | Output is correct |
22 | Correct | 178 ms | 31992 KB | Output is correct |
23 | Correct | 173 ms | 31312 KB | Output is correct |
24 | Correct | 131 ms | 23380 KB | Output is correct |
25 | Correct | 212 ms | 32080 KB | Output is correct |
26 | Correct | 154 ms | 32084 KB | Output is correct |
27 | Correct | 1 ms | 344 KB | Output is correct |
28 | Correct | 0 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 4 ms | 1116 KB | Output is correct |
32 | Correct | 1 ms | 600 KB | Output is correct |
33 | Correct | 1 ms | 604 KB | Output is correct |
34 | Correct | 266 ms | 30388 KB | Output is correct |
35 | Correct | 243 ms | 29012 KB | Output is correct |
36 | Correct | 273 ms | 32124 KB | Output is correct |
37 | Correct | 283 ms | 31768 KB | Output is correct |
38 | Correct | 171 ms | 31316 KB | Output is correct |
39 | Correct | 93 ms | 19284 KB | Output is correct |
40 | Correct | 2 ms | 856 KB | Output is correct |
41 | Correct | 3 ms | 1112 KB | Output is correct |
42 | Correct | 3 ms | 1100 KB | Output is correct |
43 | Correct | 3 ms | 1116 KB | Output is correct |
44 | Correct | 366 ms | 32024 KB | Output is correct |
45 | Correct | 366 ms | 32188 KB | Output is correct |
46 | Correct | 362 ms | 31996 KB | Output is correct |
47 | Correct | 329 ms | 32080 KB | Output is correct |
48 | Correct | 221 ms | 32084 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 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 | 1 ms | 344 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 | 0 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 | 344 KB | Output is correct |
17 | Correct | 1 ms | 344 KB | Output is correct |
18 | Correct | 1 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 | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 600 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 4 ms | 1112 KB | Output is correct |
27 | Correct | 4 ms | 1112 KB | Output is correct |
28 | Correct | 4 ms | 1116 KB | Output is correct |
29 | Correct | 4 ms | 1116 KB | Output is correct |
30 | Correct | 3 ms | 860 KB | Output is correct |
31 | Correct | 3 ms | 1116 KB | Output is correct |
32 | Correct | 4 ms | 1116 KB | Output is correct |
33 | Correct | 4 ms | 1116 KB | Output is correct |
34 | Correct | 3 ms | 1116 KB | Output is correct |
35 | Correct | 1 ms | 604 KB | Output is correct |
36 | Correct | 1 ms | 604 KB | Output is correct |
37 | Correct | 3 ms | 1116 KB | Output is correct |
38 | Correct | 3 ms | 1116 KB | Output is correct |
39 | Correct | 1 ms | 860 KB | Output is correct |
40 | Correct | 0 ms | 344 KB | Output is correct |
41 | Correct | 1 ms | 348 KB | Output is correct |
42 | Correct | 0 ms | 348 KB | Output is correct |
43 | Correct | 0 ms | 348 KB | Output is correct |
44 | Correct | 0 ms | 348 KB | Output is correct |
45 | Correct | 0 ms | 348 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Correct | 0 ms | 344 KB | Output is correct |
48 | Correct | 0 ms | 348 KB | Output is correct |
49 | Correct | 0 ms | 344 KB | Output is correct |
50 | Correct | 161 ms | 32084 KB | Output is correct |
51 | Correct | 104 ms | 21328 KB | Output is correct |
52 | Correct | 110 ms | 26452 KB | Output is correct |
53 | Correct | 201 ms | 32336 KB | Output is correct |
54 | Correct | 150 ms | 32100 KB | Output is correct |
55 | Correct | 144 ms | 32080 KB | Output is correct |
56 | Correct | 1 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 | 1 ms | 348 KB | Output is correct |
60 | Correct | 1 ms | 860 KB | Output is correct |
61 | Correct | 178 ms | 31992 KB | Output is correct |
62 | Correct | 173 ms | 31312 KB | Output is correct |
63 | Correct | 131 ms | 23380 KB | Output is correct |
64 | Correct | 212 ms | 32080 KB | Output is correct |
65 | Correct | 154 ms | 32084 KB | Output is correct |
66 | Correct | 1 ms | 344 KB | Output is correct |
67 | Correct | 0 ms | 348 KB | Output is correct |
68 | Correct | 0 ms | 348 KB | Output is correct |
69 | Correct | 0 ms | 348 KB | Output is correct |
70 | Correct | 4 ms | 1116 KB | Output is correct |
71 | Correct | 1 ms | 600 KB | Output is correct |
72 | Correct | 1 ms | 604 KB | Output is correct |
73 | Correct | 266 ms | 30388 KB | Output is correct |
74 | Correct | 243 ms | 29012 KB | Output is correct |
75 | Correct | 273 ms | 32124 KB | Output is correct |
76 | Correct | 283 ms | 31768 KB | Output is correct |
77 | Correct | 171 ms | 31316 KB | Output is correct |
78 | Correct | 93 ms | 19284 KB | Output is correct |
79 | Correct | 2 ms | 856 KB | Output is correct |
80 | Correct | 3 ms | 1112 KB | Output is correct |
81 | Correct | 3 ms | 1100 KB | Output is correct |
82 | Correct | 3 ms | 1116 KB | Output is correct |
83 | Correct | 366 ms | 32024 KB | Output is correct |
84 | Correct | 366 ms | 32188 KB | Output is correct |
85 | Correct | 362 ms | 31996 KB | Output is correct |
86 | Correct | 329 ms | 32080 KB | Output is correct |
87 | Correct | 221 ms | 32084 KB | Output is correct |
88 | Correct | 326 ms | 32128 KB | Output is correct |
89 | Correct | 353 ms | 32132 KB | Output is correct |
90 | Correct | 315 ms | 32084 KB | Output is correct |
91 | Correct | 324 ms | 32136 KB | Output is correct |
92 | Correct | 355 ms | 32084 KB | Output is correct |
93 | Correct | 328 ms | 32136 KB | Output is correct |
94 | Correct | 364 ms | 32084 KB | Output is correct |
95 | Correct | 219 ms | 32340 KB | Output is correct |
96 | Correct | 233 ms | 32028 KB | Output is correct |
97 | Correct | 178 ms | 32088 KB | Output is correct |
98 | Correct | 166 ms | 32080 KB | Output is correct |
99 | Correct | 162 ms | 32020 KB | Output is correct |