Submission #587972

# Submission time Handle Problem Language Result Execution time Memory
587972 2022-07-02T15:22:34 Z SeDunion Team Contest (JOI22_team) C++17
100 / 100
107 ms 7944 KB
#include<iostream>
#include<algorithm>
 
using namespace std;
 
const int N = 1e6 + 123;
 
using pii = pair<int,int>;
 
pii x[N], y[N], z[N];
int ix[N], iy[N], iz[N];

int used[N];
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0 ; i < n ; ++ i) {
		cin >> ix[i] >> iy[i] >> iz[i];
		x[i] = {ix[i], i};
		y[i] = {iy[i], i};
		z[i] = {iz[i], i};
	}
	sort(x, x + n);
	sort(y, y + n);
	sort(z, z + n);
	int a = n - 1, b = n - 1, c = n - 1;
	while (a >= 0 && b >= 0 && c >= 0) {
		int i = x[a].second, j = y[b].second, k = z[c].second;
      	if (iy[i] == iy[j] || iz[i] == iz[k] || used[i]) { used[i] = 1, --a; continue; }
		if (ix[i] == ix[j] || iz[j] == iz[k] || used[j]) { used[j] = 1, --b; continue; }
		if (iy[j] == iy[k] || ix[i] == ix[k] || used[k]) { used[k] = 1, --c; continue; }
		if (ix[i] > ix[j] && ix[i] > ix[k] && iy[j] > iy[i] && iy[j] > iy[k] && 
				iz[k] > iz[i] && iz[k] > iz[j]) {
			cout << ix[i] + iy[j] + iz[k];
			return 0;
		}
	}
	cout << -1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 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 1 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 340 KB Output is correct
14 Correct 1 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 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 380 KB Output is correct
21 Correct 1 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 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 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 1 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 340 KB Output is correct
14 Correct 1 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 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 380 KB Output is correct
21 Correct 1 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 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 2 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 2 ms 468 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 3 ms 468 KB Output is correct
39 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 61 ms 5584 KB Output is correct
12 Correct 47 ms 4260 KB Output is correct
13 Correct 46 ms 5084 KB Output is correct
14 Correct 65 ms 6148 KB Output is correct
15 Correct 71 ms 6220 KB Output is correct
16 Correct 32 ms 6160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 61 ms 5584 KB Output is correct
12 Correct 47 ms 4260 KB Output is correct
13 Correct 46 ms 5084 KB Output is correct
14 Correct 65 ms 6148 KB Output is correct
15 Correct 71 ms 6220 KB Output is correct
16 Correct 32 ms 6160 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 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 2 ms 340 KB Output is correct
22 Correct 73 ms 5560 KB Output is correct
23 Correct 69 ms 6016 KB Output is correct
24 Correct 53 ms 4576 KB Output is correct
25 Correct 89 ms 6144 KB Output is correct
26 Correct 82 ms 6188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 61 ms 5584 KB Output is correct
12 Correct 47 ms 4260 KB Output is correct
13 Correct 46 ms 5084 KB Output is correct
14 Correct 65 ms 6148 KB Output is correct
15 Correct 71 ms 6220 KB Output is correct
16 Correct 32 ms 6160 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 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 2 ms 340 KB Output is correct
22 Correct 73 ms 5560 KB Output is correct
23 Correct 69 ms 6016 KB Output is correct
24 Correct 53 ms 4576 KB Output is correct
25 Correct 89 ms 6144 KB Output is correct
26 Correct 82 ms 6188 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 77 ms 5388 KB Output is correct
35 Correct 80 ms 5660 KB Output is correct
36 Correct 76 ms 6120 KB Output is correct
37 Correct 83 ms 6172 KB Output is correct
38 Correct 75 ms 5980 KB Output is correct
39 Correct 29 ms 3796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 61 ms 5584 KB Output is correct
12 Correct 47 ms 4260 KB Output is correct
13 Correct 46 ms 5084 KB Output is correct
14 Correct 65 ms 6148 KB Output is correct
15 Correct 71 ms 6220 KB Output is correct
16 Correct 32 ms 6160 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 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 2 ms 340 KB Output is correct
22 Correct 73 ms 5560 KB Output is correct
23 Correct 69 ms 6016 KB Output is correct
24 Correct 53 ms 4576 KB Output is correct
25 Correct 89 ms 6144 KB Output is correct
26 Correct 82 ms 6188 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 77 ms 5388 KB Output is correct
35 Correct 80 ms 5660 KB Output is correct
36 Correct 76 ms 6120 KB Output is correct
37 Correct 83 ms 6172 KB Output is correct
38 Correct 75 ms 5980 KB Output is correct
39 Correct 29 ms 3796 KB Output is correct
40 Correct 2 ms 468 KB Output is correct
41 Correct 3 ms 468 KB Output is correct
42 Correct 1 ms 468 KB Output is correct
43 Correct 3 ms 468 KB Output is correct
44 Correct 84 ms 5644 KB Output is correct
45 Correct 99 ms 6144 KB Output is correct
46 Correct 94 ms 6152 KB Output is correct
47 Correct 93 ms 6152 KB Output is correct
48 Correct 75 ms 6196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 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 1 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 340 KB Output is correct
14 Correct 1 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 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 380 KB Output is correct
21 Correct 1 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 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 2 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 2 ms 468 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 3 ms 468 KB Output is correct
39 Correct 2 ms 340 KB Output is correct
40 Correct 0 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 61 ms 5584 KB Output is correct
51 Correct 47 ms 4260 KB Output is correct
52 Correct 46 ms 5084 KB Output is correct
53 Correct 65 ms 6148 KB Output is correct
54 Correct 71 ms 6220 KB Output is correct
55 Correct 32 ms 6160 KB Output is correct
56 Correct 0 ms 340 KB Output is correct
57 Correct 0 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 2 ms 340 KB Output is correct
61 Correct 73 ms 5560 KB Output is correct
62 Correct 69 ms 6016 KB Output is correct
63 Correct 53 ms 4576 KB Output is correct
64 Correct 89 ms 6144 KB Output is correct
65 Correct 82 ms 6188 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 4 ms 468 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 77 ms 5388 KB Output is correct
74 Correct 80 ms 5660 KB Output is correct
75 Correct 76 ms 6120 KB Output is correct
76 Correct 83 ms 6172 KB Output is correct
77 Correct 75 ms 5980 KB Output is correct
78 Correct 29 ms 3796 KB Output is correct
79 Correct 2 ms 468 KB Output is correct
80 Correct 3 ms 468 KB Output is correct
81 Correct 1 ms 468 KB Output is correct
82 Correct 3 ms 468 KB Output is correct
83 Correct 84 ms 5644 KB Output is correct
84 Correct 99 ms 6144 KB Output is correct
85 Correct 94 ms 6152 KB Output is correct
86 Correct 93 ms 6152 KB Output is correct
87 Correct 75 ms 6196 KB Output is correct
88 Correct 89 ms 5644 KB Output is correct
89 Correct 99 ms 6228 KB Output is correct
90 Correct 95 ms 6132 KB Output is correct
91 Correct 107 ms 6564 KB Output is correct
92 Correct 93 ms 7924 KB Output is correct
93 Correct 88 ms 6148 KB Output is correct
94 Correct 89 ms 6148 KB Output is correct
95 Correct 83 ms 6476 KB Output is correct
96 Correct 86 ms 6208 KB Output is correct
97 Correct 53 ms 6220 KB Output is correct
98 Correct 51 ms 5916 KB Output is correct
99 Correct 101 ms 7944 KB Output is correct