#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
const int N = 2e5 + 69;
int n, a[N], b[N], c[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
cin >> n;
set<int> st;
for (int i = 1;i <= n;i++) {
cin >> a[i] >> b[i] >> c[i];
st.insert(i);
}
while (1) {
int x = 0, y = 0, z = 0;
for (auto u : st) {
x = max(x, a[u]);
y = max(y, b[u]);
z = max(z, c[u]);
}
set<int> del;
for (auto u : st) {
if (a[u] == x && b[u] == y)
del.insert(u);
else if (a[u] == x && c[u] == z)
del.insert(u);
else if (b[u] == y && c[u] == z)
del.insert(u);
else if (a[u] == x && b[u] == y && c[u] == z)
del.insert(u);
}
if (del.empty())
break;
for (auto u : del)
st.erase(u);
}
int ans = -1;
if (st.size() > 2) {
int x = 0, y = 0, z = 0;
for (auto u : st) {
x = max(x, a[u]);
y = max(y, b[u]);
z = max(z, c[u]);
}
ans = x + y + z;
}
cout << ans << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2512 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2480 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2648 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2512 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2480 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2648 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2392 KB |
Output is correct |
26 |
Correct |
3 ms |
2648 KB |
Output is correct |
27 |
Correct |
22 ms |
2904 KB |
Output is correct |
28 |
Correct |
37 ms |
2652 KB |
Output is correct |
29 |
Correct |
58 ms |
2800 KB |
Output is correct |
30 |
Correct |
21 ms |
2652 KB |
Output is correct |
31 |
Correct |
16 ms |
2908 KB |
Output is correct |
32 |
Correct |
10 ms |
2652 KB |
Output is correct |
33 |
Correct |
2 ms |
2908 KB |
Output is correct |
34 |
Correct |
89 ms |
2804 KB |
Output is correct |
35 |
Correct |
1 ms |
2392 KB |
Output is correct |
36 |
Correct |
3 ms |
2392 KB |
Output is correct |
37 |
Correct |
2 ms |
2648 KB |
Output is correct |
38 |
Correct |
30 ms |
2744 KB |
Output is correct |
39 |
Correct |
1 ms |
2596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2520 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
60 ms |
10916 KB |
Output is correct |
12 |
Correct |
55 ms |
8540 KB |
Output is correct |
13 |
Correct |
51 ms |
9044 KB |
Output is correct |
14 |
Correct |
120 ms |
11604 KB |
Output is correct |
15 |
Correct |
74 ms |
17496 KB |
Output is correct |
16 |
Correct |
74 ms |
17396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2520 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
60 ms |
10916 KB |
Output is correct |
12 |
Correct |
55 ms |
8540 KB |
Output is correct |
13 |
Correct |
51 ms |
9044 KB |
Output is correct |
14 |
Correct |
120 ms |
11604 KB |
Output is correct |
15 |
Correct |
74 ms |
17496 KB |
Output is correct |
16 |
Correct |
74 ms |
17396 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
1 ms |
2440 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2536 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
55 ms |
10392 KB |
Output is correct |
23 |
Correct |
111 ms |
10320 KB |
Output is correct |
24 |
Correct |
101 ms |
8540 KB |
Output is correct |
25 |
Correct |
153 ms |
10836 KB |
Output is correct |
26 |
Correct |
74 ms |
17488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2520 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
60 ms |
10916 KB |
Output is correct |
12 |
Correct |
55 ms |
8540 KB |
Output is correct |
13 |
Correct |
51 ms |
9044 KB |
Output is correct |
14 |
Correct |
120 ms |
11604 KB |
Output is correct |
15 |
Correct |
74 ms |
17496 KB |
Output is correct |
16 |
Correct |
74 ms |
17396 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
1 ms |
2440 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2536 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
55 ms |
10392 KB |
Output is correct |
23 |
Correct |
111 ms |
10320 KB |
Output is correct |
24 |
Correct |
101 ms |
8540 KB |
Output is correct |
25 |
Correct |
153 ms |
10836 KB |
Output is correct |
26 |
Correct |
74 ms |
17488 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
29 |
Correct |
1 ms |
2392 KB |
Output is correct |
30 |
Correct |
1 ms |
2396 KB |
Output is correct |
31 |
Correct |
10 ms |
2524 KB |
Output is correct |
32 |
Correct |
1 ms |
2396 KB |
Output is correct |
33 |
Correct |
3 ms |
2396 KB |
Output is correct |
34 |
Correct |
50 ms |
10244 KB |
Output is correct |
35 |
Correct |
617 ms |
10068 KB |
Output is correct |
36 |
Correct |
849 ms |
10816 KB |
Output is correct |
37 |
Correct |
640 ms |
10712 KB |
Output is correct |
38 |
Correct |
77 ms |
17276 KB |
Output is correct |
39 |
Correct |
161 ms |
7504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2520 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
60 ms |
10916 KB |
Output is correct |
12 |
Correct |
55 ms |
8540 KB |
Output is correct |
13 |
Correct |
51 ms |
9044 KB |
Output is correct |
14 |
Correct |
120 ms |
11604 KB |
Output is correct |
15 |
Correct |
74 ms |
17496 KB |
Output is correct |
16 |
Correct |
74 ms |
17396 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
1 ms |
2440 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2536 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
55 ms |
10392 KB |
Output is correct |
23 |
Correct |
111 ms |
10320 KB |
Output is correct |
24 |
Correct |
101 ms |
8540 KB |
Output is correct |
25 |
Correct |
153 ms |
10836 KB |
Output is correct |
26 |
Correct |
74 ms |
17488 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
29 |
Correct |
1 ms |
2392 KB |
Output is correct |
30 |
Correct |
1 ms |
2396 KB |
Output is correct |
31 |
Correct |
10 ms |
2524 KB |
Output is correct |
32 |
Correct |
1 ms |
2396 KB |
Output is correct |
33 |
Correct |
3 ms |
2396 KB |
Output is correct |
34 |
Correct |
50 ms |
10244 KB |
Output is correct |
35 |
Correct |
617 ms |
10068 KB |
Output is correct |
36 |
Correct |
849 ms |
10816 KB |
Output is correct |
37 |
Correct |
640 ms |
10712 KB |
Output is correct |
38 |
Correct |
77 ms |
17276 KB |
Output is correct |
39 |
Correct |
161 ms |
7504 KB |
Output is correct |
40 |
Correct |
21 ms |
2652 KB |
Output is correct |
41 |
Correct |
15 ms |
2652 KB |
Output is correct |
42 |
Correct |
2 ms |
2652 KB |
Output is correct |
43 |
Correct |
29 ms |
2652 KB |
Output is correct |
44 |
Correct |
51 ms |
10788 KB |
Output is correct |
45 |
Execution timed out |
2017 ms |
11608 KB |
Time limit exceeded |
46 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2512 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2480 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2648 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2392 KB |
Output is correct |
26 |
Correct |
3 ms |
2648 KB |
Output is correct |
27 |
Correct |
22 ms |
2904 KB |
Output is correct |
28 |
Correct |
37 ms |
2652 KB |
Output is correct |
29 |
Correct |
58 ms |
2800 KB |
Output is correct |
30 |
Correct |
21 ms |
2652 KB |
Output is correct |
31 |
Correct |
16 ms |
2908 KB |
Output is correct |
32 |
Correct |
10 ms |
2652 KB |
Output is correct |
33 |
Correct |
2 ms |
2908 KB |
Output is correct |
34 |
Correct |
89 ms |
2804 KB |
Output is correct |
35 |
Correct |
1 ms |
2392 KB |
Output is correct |
36 |
Correct |
3 ms |
2392 KB |
Output is correct |
37 |
Correct |
2 ms |
2648 KB |
Output is correct |
38 |
Correct |
30 ms |
2744 KB |
Output is correct |
39 |
Correct |
1 ms |
2596 KB |
Output is correct |
40 |
Correct |
1 ms |
2396 KB |
Output is correct |
41 |
Correct |
1 ms |
2396 KB |
Output is correct |
42 |
Correct |
1 ms |
2520 KB |
Output is correct |
43 |
Correct |
1 ms |
2396 KB |
Output is correct |
44 |
Correct |
0 ms |
2396 KB |
Output is correct |
45 |
Correct |
1 ms |
2392 KB |
Output is correct |
46 |
Correct |
1 ms |
2396 KB |
Output is correct |
47 |
Correct |
1 ms |
2392 KB |
Output is correct |
48 |
Correct |
1 ms |
2392 KB |
Output is correct |
49 |
Correct |
1 ms |
2396 KB |
Output is correct |
50 |
Correct |
60 ms |
10916 KB |
Output is correct |
51 |
Correct |
55 ms |
8540 KB |
Output is correct |
52 |
Correct |
51 ms |
9044 KB |
Output is correct |
53 |
Correct |
120 ms |
11604 KB |
Output is correct |
54 |
Correct |
74 ms |
17496 KB |
Output is correct |
55 |
Correct |
74 ms |
17396 KB |
Output is correct |
56 |
Correct |
1 ms |
2652 KB |
Output is correct |
57 |
Correct |
1 ms |
2440 KB |
Output is correct |
58 |
Correct |
1 ms |
2396 KB |
Output is correct |
59 |
Correct |
1 ms |
2536 KB |
Output is correct |
60 |
Correct |
1 ms |
2396 KB |
Output is correct |
61 |
Correct |
55 ms |
10392 KB |
Output is correct |
62 |
Correct |
111 ms |
10320 KB |
Output is correct |
63 |
Correct |
101 ms |
8540 KB |
Output is correct |
64 |
Correct |
153 ms |
10836 KB |
Output is correct |
65 |
Correct |
74 ms |
17488 KB |
Output is correct |
66 |
Correct |
1 ms |
2396 KB |
Output is correct |
67 |
Correct |
1 ms |
2396 KB |
Output is correct |
68 |
Correct |
1 ms |
2392 KB |
Output is correct |
69 |
Correct |
1 ms |
2396 KB |
Output is correct |
70 |
Correct |
10 ms |
2524 KB |
Output is correct |
71 |
Correct |
1 ms |
2396 KB |
Output is correct |
72 |
Correct |
3 ms |
2396 KB |
Output is correct |
73 |
Correct |
50 ms |
10244 KB |
Output is correct |
74 |
Correct |
617 ms |
10068 KB |
Output is correct |
75 |
Correct |
849 ms |
10816 KB |
Output is correct |
76 |
Correct |
640 ms |
10712 KB |
Output is correct |
77 |
Correct |
77 ms |
17276 KB |
Output is correct |
78 |
Correct |
161 ms |
7504 KB |
Output is correct |
79 |
Correct |
21 ms |
2652 KB |
Output is correct |
80 |
Correct |
15 ms |
2652 KB |
Output is correct |
81 |
Correct |
2 ms |
2652 KB |
Output is correct |
82 |
Correct |
29 ms |
2652 KB |
Output is correct |
83 |
Correct |
51 ms |
10788 KB |
Output is correct |
84 |
Execution timed out |
2017 ms |
11608 KB |
Time limit exceeded |
85 |
Halted |
0 ms |
0 KB |
- |