Submission #852113

# Submission time Handle Problem Language Result Execution time Memory
852113 2023-09-21T09:06:25 Z iee Team Contest (JOI22_team) C++17
100 / 100
325 ms 27416 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<vector<int>> V(3, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> V[j][i];
		}
	}
	vector<set<pair<int, int>>> se(3);
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < n; j++) {
			se[i].emplace(V[i][j], j);
		}
	}
	while (!se[0].empty()) {
		vector<int> id, mx;
		for (int i = 0; i < 3; i++) {
			id.push_back(se[i].rbegin()->second);
			mx.push_back(se[i].rbegin()->first);
		}
		set<int> to_erase;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (j != i && mx[j] == V[j][id[i]]) {
					to_erase.insert(id[i]);
				}
			}
		}
		if (to_erase.empty()) {
			cout << accumulate(mx.begin(), mx.end(), 0) << "\n";
			return 0;
		}
		for (int i : to_erase) {
			for (int j = 0; j < 3; j++) {
				se[j].erase({V[j][i], i});
			}
		}
	}
	cout << -1 << "\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 456 KB Output is correct
4 Correct 0 ms 344 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 352 KB Output is correct
9 Correct 0 ms 352 KB Output is correct
10 Correct 0 ms 352 KB Output is correct
11 Correct 0 ms 352 KB Output is correct
12 Correct 0 ms 352 KB Output is correct
13 Correct 0 ms 352 KB Output is correct
14 Correct 1 ms 356 KB Output is correct
15 Correct 1 ms 352 KB Output is correct
16 Correct 1 ms 352 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 1 ms 352 KB Output is correct
19 Correct 1 ms 352 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 464 KB Output is correct
24 Correct 1 ms 356 KB Output is correct
25 Correct 1 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 456 KB Output is correct
4 Correct 0 ms 344 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 352 KB Output is correct
9 Correct 0 ms 352 KB Output is correct
10 Correct 0 ms 352 KB Output is correct
11 Correct 0 ms 352 KB Output is correct
12 Correct 0 ms 352 KB Output is correct
13 Correct 0 ms 352 KB Output is correct
14 Correct 1 ms 356 KB Output is correct
15 Correct 1 ms 352 KB Output is correct
16 Correct 1 ms 352 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 1 ms 352 KB Output is correct
19 Correct 1 ms 352 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 464 KB Output is correct
24 Correct 1 ms 356 KB Output is correct
25 Correct 1 ms 356 KB Output is correct
26 Correct 3 ms 1120 KB Output is correct
27 Correct 3 ms 1176 KB Output is correct
28 Correct 4 ms 1116 KB Output is correct
29 Correct 5 ms 1144 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 3 ms 1048 KB Output is correct
32 Correct 5 ms 856 KB Output is correct
33 Correct 4 ms 1112 KB Output is correct
34 Correct 4 ms 980 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 2 ms 1116 KB Output is correct
38 Correct 4 ms 1116 KB Output is correct
39 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 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 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 95 ms 24188 KB Output is correct
12 Correct 97 ms 16340 KB Output is correct
13 Correct 69 ms 20016 KB Output is correct
14 Correct 177 ms 24068 KB Output is correct
15 Correct 125 ms 24036 KB Output is correct
16 Correct 145 ms 24184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 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 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 95 ms 24188 KB Output is correct
12 Correct 97 ms 16340 KB Output is correct
13 Correct 69 ms 20016 KB Output is correct
14 Correct 177 ms 24068 KB Output is correct
15 Correct 125 ms 24036 KB Output is correct
16 Correct 145 ms 24184 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 352 KB Output is correct
20 Correct 1 ms 356 KB Output is correct
21 Correct 1 ms 612 KB Output is correct
22 Correct 111 ms 24580 KB Output is correct
23 Correct 128 ms 23660 KB Output is correct
24 Correct 131 ms 17808 KB Output is correct
25 Correct 268 ms 24364 KB Output is correct
26 Correct 134 ms 24432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 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 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 95 ms 24188 KB Output is correct
12 Correct 97 ms 16340 KB Output is correct
13 Correct 69 ms 20016 KB Output is correct
14 Correct 177 ms 24068 KB Output is correct
15 Correct 125 ms 24036 KB Output is correct
16 Correct 145 ms 24184 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 352 KB Output is correct
20 Correct 1 ms 356 KB Output is correct
21 Correct 1 ms 612 KB Output is correct
22 Correct 111 ms 24580 KB Output is correct
23 Correct 128 ms 23660 KB Output is correct
24 Correct 131 ms 17808 KB Output is correct
25 Correct 268 ms 24364 KB Output is correct
26 Correct 134 ms 24432 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 5 ms 984 KB Output is correct
32 Correct 1 ms 356 KB Output is correct
33 Correct 1 ms 608 KB Output is correct
34 Correct 139 ms 23632 KB Output is correct
35 Correct 191 ms 22672 KB Output is correct
36 Correct 211 ms 24836 KB Output is correct
37 Correct 324 ms 24816 KB Output is correct
38 Correct 154 ms 24192 KB Output is correct
39 Correct 98 ms 15176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 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 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 95 ms 24188 KB Output is correct
12 Correct 97 ms 16340 KB Output is correct
13 Correct 69 ms 20016 KB Output is correct
14 Correct 177 ms 24068 KB Output is correct
15 Correct 125 ms 24036 KB Output is correct
16 Correct 145 ms 24184 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 352 KB Output is correct
20 Correct 1 ms 356 KB Output is correct
21 Correct 1 ms 612 KB Output is correct
22 Correct 111 ms 24580 KB Output is correct
23 Correct 128 ms 23660 KB Output is correct
24 Correct 131 ms 17808 KB Output is correct
25 Correct 268 ms 24364 KB Output is correct
26 Correct 134 ms 24432 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 5 ms 984 KB Output is correct
32 Correct 1 ms 356 KB Output is correct
33 Correct 1 ms 608 KB Output is correct
34 Correct 139 ms 23632 KB Output is correct
35 Correct 191 ms 22672 KB Output is correct
36 Correct 211 ms 24836 KB Output is correct
37 Correct 324 ms 24816 KB Output is correct
38 Correct 154 ms 24192 KB Output is correct
39 Correct 98 ms 15176 KB Output is correct
40 Correct 3 ms 860 KB Output is correct
41 Correct 3 ms 860 KB Output is correct
42 Correct 2 ms 1116 KB Output is correct
43 Correct 3 ms 1080 KB Output is correct
44 Correct 164 ms 25316 KB Output is correct
45 Correct 310 ms 25348 KB Output is correct
46 Correct 289 ms 25332 KB Output is correct
47 Correct 325 ms 25604 KB Output is correct
48 Correct 167 ms 25352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 456 KB Output is correct
4 Correct 0 ms 344 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 352 KB Output is correct
9 Correct 0 ms 352 KB Output is correct
10 Correct 0 ms 352 KB Output is correct
11 Correct 0 ms 352 KB Output is correct
12 Correct 0 ms 352 KB Output is correct
13 Correct 0 ms 352 KB Output is correct
14 Correct 1 ms 356 KB Output is correct
15 Correct 1 ms 352 KB Output is correct
16 Correct 1 ms 352 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 1 ms 352 KB Output is correct
19 Correct 1 ms 352 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 464 KB Output is correct
24 Correct 1 ms 356 KB Output is correct
25 Correct 1 ms 356 KB Output is correct
26 Correct 3 ms 1120 KB Output is correct
27 Correct 3 ms 1176 KB Output is correct
28 Correct 4 ms 1116 KB Output is correct
29 Correct 5 ms 1144 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 3 ms 1048 KB Output is correct
32 Correct 5 ms 856 KB Output is correct
33 Correct 4 ms 1112 KB Output is correct
34 Correct 4 ms 980 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 2 ms 1116 KB Output is correct
38 Correct 4 ms 1116 KB Output is correct
39 Correct 1 ms 604 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 344 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 348 KB Output is correct
48 Correct 1 ms 344 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 95 ms 24188 KB Output is correct
51 Correct 97 ms 16340 KB Output is correct
52 Correct 69 ms 20016 KB Output is correct
53 Correct 177 ms 24068 KB Output is correct
54 Correct 125 ms 24036 KB Output is correct
55 Correct 145 ms 24184 KB Output is correct
56 Correct 0 ms 344 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 0 ms 352 KB Output is correct
59 Correct 1 ms 356 KB Output is correct
60 Correct 1 ms 612 KB Output is correct
61 Correct 111 ms 24580 KB Output is correct
62 Correct 128 ms 23660 KB Output is correct
63 Correct 131 ms 17808 KB Output is correct
64 Correct 268 ms 24364 KB Output is correct
65 Correct 134 ms 24432 KB Output is correct
66 Correct 1 ms 344 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 1 ms 348 KB Output is correct
70 Correct 5 ms 984 KB Output is correct
71 Correct 1 ms 356 KB Output is correct
72 Correct 1 ms 608 KB Output is correct
73 Correct 139 ms 23632 KB Output is correct
74 Correct 191 ms 22672 KB Output is correct
75 Correct 211 ms 24836 KB Output is correct
76 Correct 324 ms 24816 KB Output is correct
77 Correct 154 ms 24192 KB Output is correct
78 Correct 98 ms 15176 KB Output is correct
79 Correct 3 ms 860 KB Output is correct
80 Correct 3 ms 860 KB Output is correct
81 Correct 2 ms 1116 KB Output is correct
82 Correct 3 ms 1080 KB Output is correct
83 Correct 164 ms 25316 KB Output is correct
84 Correct 310 ms 25348 KB Output is correct
85 Correct 289 ms 25332 KB Output is correct
86 Correct 325 ms 25604 KB Output is correct
87 Correct 167 ms 25352 KB Output is correct
88 Correct 164 ms 27140 KB Output is correct
89 Correct 257 ms 27256 KB Output is correct
90 Correct 185 ms 27156 KB Output is correct
91 Correct 314 ms 27304 KB Output is correct
92 Correct 208 ms 25760 KB Output is correct
93 Correct 286 ms 26100 KB Output is correct
94 Correct 323 ms 25888 KB Output is correct
95 Correct 185 ms 26884 KB Output is correct
96 Correct 228 ms 27416 KB Output is correct
97 Correct 163 ms 27396 KB Output is correct
98 Correct 100 ms 25860 KB Output is correct
99 Correct 161 ms 25764 KB Output is correct