답안 #641597

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
641597 2022-09-17T07:06:19 Z onlk97 Team Contest (JOI22_team) C++14
100 / 100
230 ms 10264 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1][3];
	for (int i=1; i<=n; i++){
		for (int j=0; j<3; j++) cin>>a[i][j];
	}
	priority_queue <pair <int,int> > pq[3];
	for (int i=1; i<=n; i++){
		for (int j=0; j<3; j++) pq[j].push(make_pair(a[i][j],i));
	}
	bool removed[n+1];
	for (int i=1; i<=n; i++) removed[i]=0;
	for (;;){
		if (!pq[0].size()||!pq[1].size()||!pq[2].size()) break;
		bool ok=1;
		for (int j=0; j<3; j++){
			if (removed[pq[j].top().second]){
				pq[j].pop();
				ok=0;
				break;
			}
			for (int k=0; k<3; k++){
				if (j==k) continue;
				if (a[pq[j].top().second][k]==pq[k].top().first){
					removed[pq[j].top().second]=1;
					pq[j].pop();
					ok=0;
					break;
				}
			}
			if (!ok) break;
		}
		if (ok){
			cout<<pq[0].top().first+pq[1].top().first+pq[2].top().first<<'\n';
			return 0;
		}
	}
	cout<<"-1\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 5 ms 564 KB Output is correct
27 Correct 5 ms 468 KB Output is correct
28 Correct 5 ms 468 KB Output is correct
29 Correct 7 ms 468 KB Output is correct
30 Correct 5 ms 468 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 4 ms 468 KB Output is correct
33 Correct 6 ms 564 KB Output is correct
34 Correct 6 ms 576 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 5 ms 468 KB Output is correct
38 Correct 5 ms 468 KB Output is correct
39 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 75 ms 7116 KB Output is correct
12 Correct 72 ms 4732 KB Output is correct
13 Correct 64 ms 5536 KB Output is correct
14 Correct 104 ms 7092 KB Output is correct
15 Correct 92 ms 7092 KB Output is correct
16 Correct 90 ms 7120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 75 ms 7116 KB Output is correct
12 Correct 72 ms 4732 KB Output is correct
13 Correct 64 ms 5536 KB Output is correct
14 Correct 104 ms 7092 KB Output is correct
15 Correct 92 ms 7092 KB Output is correct
16 Correct 90 ms 7120 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 82 ms 7364 KB Output is correct
23 Correct 87 ms 7196 KB Output is correct
24 Correct 88 ms 5148 KB Output is correct
25 Correct 129 ms 7396 KB Output is correct
26 Correct 95 ms 7248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 75 ms 7116 KB Output is correct
12 Correct 72 ms 4732 KB Output is correct
13 Correct 64 ms 5536 KB Output is correct
14 Correct 104 ms 7092 KB Output is correct
15 Correct 92 ms 7092 KB Output is correct
16 Correct 90 ms 7120 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 82 ms 7364 KB Output is correct
23 Correct 87 ms 7196 KB Output is correct
24 Correct 88 ms 5148 KB Output is correct
25 Correct 129 ms 7396 KB Output is correct
26 Correct 95 ms 7248 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 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 308 KB Output is correct
34 Correct 90 ms 7668 KB Output is correct
35 Correct 117 ms 7596 KB Output is correct
36 Correct 124 ms 7772 KB Output is correct
37 Correct 152 ms 7868 KB Output is correct
38 Correct 114 ms 7732 KB Output is correct
39 Correct 70 ms 4604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 75 ms 7116 KB Output is correct
12 Correct 72 ms 4732 KB Output is correct
13 Correct 64 ms 5536 KB Output is correct
14 Correct 104 ms 7092 KB Output is correct
15 Correct 92 ms 7092 KB Output is correct
16 Correct 90 ms 7120 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 296 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 82 ms 7364 KB Output is correct
23 Correct 87 ms 7196 KB Output is correct
24 Correct 88 ms 5148 KB Output is correct
25 Correct 129 ms 7396 KB Output is correct
26 Correct 95 ms 7248 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 300 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 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 308 KB Output is correct
34 Correct 90 ms 7668 KB Output is correct
35 Correct 117 ms 7596 KB Output is correct
36 Correct 124 ms 7772 KB Output is correct
37 Correct 152 ms 7868 KB Output is correct
38 Correct 114 ms 7732 KB Output is correct
39 Correct 70 ms 4604 KB Output is correct
40 Correct 3 ms 468 KB Output is correct
41 Correct 3 ms 468 KB Output is correct
42 Correct 5 ms 516 KB Output is correct
43 Correct 6 ms 440 KB Output is correct
44 Correct 135 ms 8392 KB Output is correct
45 Correct 175 ms 8396 KB Output is correct
46 Correct 148 ms 8296 KB Output is correct
47 Correct 181 ms 8392 KB Output is correct
48 Correct 165 ms 8272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 5 ms 564 KB Output is correct
27 Correct 5 ms 468 KB Output is correct
28 Correct 5 ms 468 KB Output is correct
29 Correct 7 ms 468 KB Output is correct
30 Correct 5 ms 468 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 4 ms 468 KB Output is correct
33 Correct 6 ms 564 KB Output is correct
34 Correct 6 ms 576 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 5 ms 468 KB Output is correct
38 Correct 5 ms 468 KB Output is correct
39 Correct 2 ms 340 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 308 KB Output is correct
44 Correct 1 ms 292 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 300 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 300 KB Output is correct
50 Correct 75 ms 7116 KB Output is correct
51 Correct 72 ms 4732 KB Output is correct
52 Correct 64 ms 5536 KB Output is correct
53 Correct 104 ms 7092 KB Output is correct
54 Correct 92 ms 7092 KB Output is correct
55 Correct 90 ms 7120 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 0 ms 296 KB Output is correct
59 Correct 1 ms 300 KB Output is correct
60 Correct 2 ms 340 KB Output is correct
61 Correct 82 ms 7364 KB Output is correct
62 Correct 87 ms 7196 KB Output is correct
63 Correct 88 ms 5148 KB Output is correct
64 Correct 129 ms 7396 KB Output is correct
65 Correct 95 ms 7248 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 300 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 212 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 308 KB Output is correct
73 Correct 90 ms 7668 KB Output is correct
74 Correct 117 ms 7596 KB Output is correct
75 Correct 124 ms 7772 KB Output is correct
76 Correct 152 ms 7868 KB Output is correct
77 Correct 114 ms 7732 KB Output is correct
78 Correct 70 ms 4604 KB Output is correct
79 Correct 3 ms 468 KB Output is correct
80 Correct 3 ms 468 KB Output is correct
81 Correct 5 ms 516 KB Output is correct
82 Correct 6 ms 440 KB Output is correct
83 Correct 135 ms 8392 KB Output is correct
84 Correct 175 ms 8396 KB Output is correct
85 Correct 148 ms 8296 KB Output is correct
86 Correct 181 ms 8392 KB Output is correct
87 Correct 165 ms 8272 KB Output is correct
88 Correct 165 ms 10200 KB Output is correct
89 Correct 210 ms 10264 KB Output is correct
90 Correct 177 ms 10196 KB Output is correct
91 Correct 230 ms 10188 KB Output is correct
92 Correct 146 ms 8656 KB Output is correct
93 Correct 178 ms 9040 KB Output is correct
94 Correct 182 ms 8884 KB Output is correct
95 Correct 184 ms 10036 KB Output is correct
96 Correct 195 ms 10180 KB Output is correct
97 Correct 177 ms 10188 KB Output is correct
98 Correct 132 ms 8788 KB Output is correct
99 Correct 161 ms 8908 KB Output is correct