# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1059894 |
2024-08-15T08:56:11 Z |
_8_8_ |
Team Contest (JOI22_team) |
C++17 |
|
357 ms |
36948 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int N = 2e5 + 2, MOD = 998244353;
int a[N],b[N],c[N],n;
set<pair<int,int>> x,y,z;
void del(int i) {
x.erase({a[i],i});
y.erase({b[i],i});
z.erase({c[i],i});
}
void test() {
cin >> n;
for(int i = 1;i <= n;i++) {
cin >> a[i] >> b[i] >> c[i];
x.insert({a[i],i});
y.insert({b[i],i});
z.insert({c[i],i});
}
while(true) {
if(x.empty()) {
cout << -1;
return;
}
auto [v,i] = (*x.rbegin());
auto [v1,j] = (*y.rbegin());
auto [v2,k] = (*z.rbegin());
auto bad = [&](int id)->bool{
int col = 0;
if(a[id] == (*x.rbegin()).first) col++;
if(b[id] == (*y.rbegin()).first) col++;
if(c[id] == (*z.rbegin()).first) col++;
if(col > 1) return 1;
return 0;
};
if(i == j && j == k) {
del(i);
continue;
}
if(i == j || i == k) {
del(i);
continue;
} else if(j == k) {
del(j);
continue;
}
bool ok = 1;
if(bad(i)) {
ok = false;
del(i);
}
if(bad(j)) {
ok = false;
del(j);
}
if(bad(k)) {
ok = false;
del(k);
}
if(ok) {
cout << v + v1 + v2;
return;
}
}
}
signed main() {
ios_base::sync_with_stdio(false);cin.tie(0);
int t = 1;
// cin >> t;
while(t--) {
test();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4440 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
2 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4564 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4440 KB |
Output is correct |
20 |
Correct |
1 ms |
4624 KB |
Output is correct |
21 |
Correct |
1 ms |
4444 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4440 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
2 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4564 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4440 KB |
Output is correct |
20 |
Correct |
1 ms |
4624 KB |
Output is correct |
21 |
Correct |
1 ms |
4444 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
1 ms |
4444 KB |
Output is correct |
26 |
Correct |
3 ms |
5212 KB |
Output is correct |
27 |
Correct |
4 ms |
5212 KB |
Output is correct |
28 |
Correct |
4 ms |
5212 KB |
Output is correct |
29 |
Correct |
4 ms |
5232 KB |
Output is correct |
30 |
Correct |
3 ms |
5096 KB |
Output is correct |
31 |
Correct |
3 ms |
5212 KB |
Output is correct |
32 |
Correct |
4 ms |
5212 KB |
Output is correct |
33 |
Correct |
3 ms |
5272 KB |
Output is correct |
34 |
Correct |
3 ms |
5212 KB |
Output is correct |
35 |
Correct |
1 ms |
4700 KB |
Output is correct |
36 |
Correct |
1 ms |
4700 KB |
Output is correct |
37 |
Correct |
2 ms |
5212 KB |
Output is correct |
38 |
Correct |
3 ms |
5212 KB |
Output is correct |
39 |
Correct |
2 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
0 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4696 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
0 ms |
4444 KB |
Output is correct |
11 |
Correct |
127 ms |
33580 KB |
Output is correct |
12 |
Correct |
112 ms |
24084 KB |
Output is correct |
13 |
Correct |
91 ms |
28500 KB |
Output is correct |
14 |
Correct |
160 ms |
33616 KB |
Output is correct |
15 |
Correct |
123 ms |
33616 KB |
Output is correct |
16 |
Correct |
128 ms |
33788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
0 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4696 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
0 ms |
4444 KB |
Output is correct |
11 |
Correct |
127 ms |
33580 KB |
Output is correct |
12 |
Correct |
112 ms |
24084 KB |
Output is correct |
13 |
Correct |
91 ms |
28500 KB |
Output is correct |
14 |
Correct |
160 ms |
33616 KB |
Output is correct |
15 |
Correct |
123 ms |
33616 KB |
Output is correct |
16 |
Correct |
128 ms |
33788 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4560 KB |
Output is correct |
21 |
Correct |
2 ms |
4956 KB |
Output is correct |
22 |
Correct |
147 ms |
33968 KB |
Output is correct |
23 |
Correct |
152 ms |
33108 KB |
Output is correct |
24 |
Correct |
151 ms |
25808 KB |
Output is correct |
25 |
Correct |
204 ms |
33852 KB |
Output is correct |
26 |
Correct |
127 ms |
34080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
0 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4696 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
0 ms |
4444 KB |
Output is correct |
11 |
Correct |
127 ms |
33580 KB |
Output is correct |
12 |
Correct |
112 ms |
24084 KB |
Output is correct |
13 |
Correct |
91 ms |
28500 KB |
Output is correct |
14 |
Correct |
160 ms |
33616 KB |
Output is correct |
15 |
Correct |
123 ms |
33616 KB |
Output is correct |
16 |
Correct |
128 ms |
33788 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4560 KB |
Output is correct |
21 |
Correct |
2 ms |
4956 KB |
Output is correct |
22 |
Correct |
147 ms |
33968 KB |
Output is correct |
23 |
Correct |
152 ms |
33108 KB |
Output is correct |
24 |
Correct |
151 ms |
25808 KB |
Output is correct |
25 |
Correct |
204 ms |
33852 KB |
Output is correct |
26 |
Correct |
127 ms |
34080 KB |
Output is correct |
27 |
Correct |
1 ms |
4444 KB |
Output is correct |
28 |
Correct |
1 ms |
4444 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4440 KB |
Output is correct |
31 |
Correct |
4 ms |
5208 KB |
Output is correct |
32 |
Correct |
1 ms |
4700 KB |
Output is correct |
33 |
Correct |
1 ms |
4700 KB |
Output is correct |
34 |
Correct |
217 ms |
32892 KB |
Output is correct |
35 |
Correct |
241 ms |
31572 KB |
Output is correct |
36 |
Correct |
268 ms |
34380 KB |
Output is correct |
37 |
Correct |
300 ms |
34132 KB |
Output is correct |
38 |
Correct |
161 ms |
33632 KB |
Output is correct |
39 |
Correct |
87 ms |
22612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4696 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
0 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4696 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
0 ms |
4444 KB |
Output is correct |
11 |
Correct |
127 ms |
33580 KB |
Output is correct |
12 |
Correct |
112 ms |
24084 KB |
Output is correct |
13 |
Correct |
91 ms |
28500 KB |
Output is correct |
14 |
Correct |
160 ms |
33616 KB |
Output is correct |
15 |
Correct |
123 ms |
33616 KB |
Output is correct |
16 |
Correct |
128 ms |
33788 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4444 KB |
Output is correct |
20 |
Correct |
1 ms |
4560 KB |
Output is correct |
21 |
Correct |
2 ms |
4956 KB |
Output is correct |
22 |
Correct |
147 ms |
33968 KB |
Output is correct |
23 |
Correct |
152 ms |
33108 KB |
Output is correct |
24 |
Correct |
151 ms |
25808 KB |
Output is correct |
25 |
Correct |
204 ms |
33852 KB |
Output is correct |
26 |
Correct |
127 ms |
34080 KB |
Output is correct |
27 |
Correct |
1 ms |
4444 KB |
Output is correct |
28 |
Correct |
1 ms |
4444 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4440 KB |
Output is correct |
31 |
Correct |
4 ms |
5208 KB |
Output is correct |
32 |
Correct |
1 ms |
4700 KB |
Output is correct |
33 |
Correct |
1 ms |
4700 KB |
Output is correct |
34 |
Correct |
217 ms |
32892 KB |
Output is correct |
35 |
Correct |
241 ms |
31572 KB |
Output is correct |
36 |
Correct |
268 ms |
34380 KB |
Output is correct |
37 |
Correct |
300 ms |
34132 KB |
Output is correct |
38 |
Correct |
161 ms |
33632 KB |
Output is correct |
39 |
Correct |
87 ms |
22612 KB |
Output is correct |
40 |
Correct |
3 ms |
4956 KB |
Output is correct |
41 |
Correct |
4 ms |
5212 KB |
Output is correct |
42 |
Correct |
3 ms |
5212 KB |
Output is correct |
43 |
Correct |
3 ms |
5212 KB |
Output is correct |
44 |
Correct |
246 ms |
34820 KB |
Output is correct |
45 |
Correct |
308 ms |
34900 KB |
Output is correct |
46 |
Correct |
273 ms |
34896 KB |
Output is correct |
47 |
Correct |
304 ms |
35156 KB |
Output is correct |
48 |
Correct |
177 ms |
34900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4440 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
2 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4564 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
1 ms |
4440 KB |
Output is correct |
20 |
Correct |
1 ms |
4624 KB |
Output is correct |
21 |
Correct |
1 ms |
4444 KB |
Output is correct |
22 |
Correct |
1 ms |
4444 KB |
Output is correct |
23 |
Correct |
1 ms |
4444 KB |
Output is correct |
24 |
Correct |
1 ms |
4444 KB |
Output is correct |
25 |
Correct |
1 ms |
4444 KB |
Output is correct |
26 |
Correct |
3 ms |
5212 KB |
Output is correct |
27 |
Correct |
4 ms |
5212 KB |
Output is correct |
28 |
Correct |
4 ms |
5212 KB |
Output is correct |
29 |
Correct |
4 ms |
5232 KB |
Output is correct |
30 |
Correct |
3 ms |
5096 KB |
Output is correct |
31 |
Correct |
3 ms |
5212 KB |
Output is correct |
32 |
Correct |
4 ms |
5212 KB |
Output is correct |
33 |
Correct |
3 ms |
5272 KB |
Output is correct |
34 |
Correct |
3 ms |
5212 KB |
Output is correct |
35 |
Correct |
1 ms |
4700 KB |
Output is correct |
36 |
Correct |
1 ms |
4700 KB |
Output is correct |
37 |
Correct |
2 ms |
5212 KB |
Output is correct |
38 |
Correct |
3 ms |
5212 KB |
Output is correct |
39 |
Correct |
2 ms |
4956 KB |
Output is correct |
40 |
Correct |
1 ms |
4696 KB |
Output is correct |
41 |
Correct |
1 ms |
4444 KB |
Output is correct |
42 |
Correct |
1 ms |
4444 KB |
Output is correct |
43 |
Correct |
0 ms |
4444 KB |
Output is correct |
44 |
Correct |
1 ms |
4696 KB |
Output is correct |
45 |
Correct |
1 ms |
4444 KB |
Output is correct |
46 |
Correct |
1 ms |
4444 KB |
Output is correct |
47 |
Correct |
1 ms |
4444 KB |
Output is correct |
48 |
Correct |
1 ms |
4444 KB |
Output is correct |
49 |
Correct |
0 ms |
4444 KB |
Output is correct |
50 |
Correct |
127 ms |
33580 KB |
Output is correct |
51 |
Correct |
112 ms |
24084 KB |
Output is correct |
52 |
Correct |
91 ms |
28500 KB |
Output is correct |
53 |
Correct |
160 ms |
33616 KB |
Output is correct |
54 |
Correct |
123 ms |
33616 KB |
Output is correct |
55 |
Correct |
128 ms |
33788 KB |
Output is correct |
56 |
Correct |
1 ms |
4444 KB |
Output is correct |
57 |
Correct |
1 ms |
4444 KB |
Output is correct |
58 |
Correct |
1 ms |
4444 KB |
Output is correct |
59 |
Correct |
1 ms |
4560 KB |
Output is correct |
60 |
Correct |
2 ms |
4956 KB |
Output is correct |
61 |
Correct |
147 ms |
33968 KB |
Output is correct |
62 |
Correct |
152 ms |
33108 KB |
Output is correct |
63 |
Correct |
151 ms |
25808 KB |
Output is correct |
64 |
Correct |
204 ms |
33852 KB |
Output is correct |
65 |
Correct |
127 ms |
34080 KB |
Output is correct |
66 |
Correct |
1 ms |
4444 KB |
Output is correct |
67 |
Correct |
1 ms |
4444 KB |
Output is correct |
68 |
Correct |
1 ms |
4444 KB |
Output is correct |
69 |
Correct |
1 ms |
4440 KB |
Output is correct |
70 |
Correct |
4 ms |
5208 KB |
Output is correct |
71 |
Correct |
1 ms |
4700 KB |
Output is correct |
72 |
Correct |
1 ms |
4700 KB |
Output is correct |
73 |
Correct |
217 ms |
32892 KB |
Output is correct |
74 |
Correct |
241 ms |
31572 KB |
Output is correct |
75 |
Correct |
268 ms |
34380 KB |
Output is correct |
76 |
Correct |
300 ms |
34132 KB |
Output is correct |
77 |
Correct |
161 ms |
33632 KB |
Output is correct |
78 |
Correct |
87 ms |
22612 KB |
Output is correct |
79 |
Correct |
3 ms |
4956 KB |
Output is correct |
80 |
Correct |
4 ms |
5212 KB |
Output is correct |
81 |
Correct |
3 ms |
5212 KB |
Output is correct |
82 |
Correct |
3 ms |
5212 KB |
Output is correct |
83 |
Correct |
246 ms |
34820 KB |
Output is correct |
84 |
Correct |
308 ms |
34900 KB |
Output is correct |
85 |
Correct |
273 ms |
34896 KB |
Output is correct |
86 |
Correct |
304 ms |
35156 KB |
Output is correct |
87 |
Correct |
177 ms |
34900 KB |
Output is correct |
88 |
Correct |
222 ms |
36692 KB |
Output is correct |
89 |
Correct |
287 ms |
36948 KB |
Output is correct |
90 |
Correct |
241 ms |
36688 KB |
Output is correct |
91 |
Correct |
283 ms |
36564 KB |
Output is correct |
92 |
Correct |
271 ms |
35288 KB |
Output is correct |
93 |
Correct |
357 ms |
35560 KB |
Output is correct |
94 |
Correct |
352 ms |
35376 KB |
Output is correct |
95 |
Correct |
202 ms |
36456 KB |
Output is correct |
96 |
Correct |
167 ms |
36692 KB |
Output is correct |
97 |
Correct |
159 ms |
36656 KB |
Output is correct |
98 |
Correct |
118 ms |
35324 KB |
Output is correct |
99 |
Correct |
145 ms |
35436 KB |
Output is correct |