답안 #591878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
591878 2022-07-08T05:38:49 Z 이동현(#8425) Team Contest (JOI22_team) C++17
100 / 100
260 ms 16636 KB
#include <bits/stdc++.h>

using namespace std;

int main(){
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(3));
    vector<priority_queue<pair<int, int>>> pq(3);
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < 3; ++j){
            cin >> a[i][j];
            pq[j].push(make_pair(a[i][j], i));
        }
    }
    vector<int> chk(n);
    while(true){
        int f = 1;
        for(int i = 0; i < 3; ++i){
            for(int j = 0; j < 3; ++j){
                while((int)pq[j].size() && chk[pq[j].top().second]){
                    pq[j].pop();
                }
            }
            if(!(int)pq[i].size()){
                f = 0;
                break;
            }
            int kill = 0;
            for(int j = 0; j < 3; ++j){
                if(pq[j].top().first == a[pq[i].top().second][j]){
                    ++kill;
                }
            }
            if(kill >= 2){
                f = 0;
                chk[pq[i].top().second] = 1;
                break;
            }
        }
        if(f || pq[0].empty()){
            break;
        }
    }
    if(!(int)pq[0].size()){
        cout << "-1\n";
        return 0;
    }
    cout << pq[0].top().first + pq[1].top().first + pq[2].top().first << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 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 0 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 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 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 0 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 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 5 ms 640 KB Output is correct
27 Correct 5 ms 648 KB Output is correct
28 Correct 5 ms 596 KB Output is correct
29 Correct 6 ms 596 KB Output is correct
30 Correct 3 ms 468 KB Output is correct
31 Correct 4 ms 596 KB Output is correct
32 Correct 5 ms 644 KB Output is correct
33 Correct 6 ms 596 KB Output is correct
34 Correct 7 ms 644 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 3 ms 596 KB Output is correct
38 Correct 4 ms 596 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 113 ms 12860 KB Output is correct
12 Correct 80 ms 9120 KB Output is correct
13 Correct 71 ms 11148 KB Output is correct
14 Correct 137 ms 13776 KB Output is correct
15 Correct 129 ms 13800 KB Output is correct
16 Correct 110 ms 13676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 113 ms 12860 KB Output is correct
12 Correct 80 ms 9120 KB Output is correct
13 Correct 71 ms 11148 KB Output is correct
14 Correct 137 ms 13776 KB Output is correct
15 Correct 129 ms 13800 KB Output is correct
16 Correct 110 ms 13676 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 300 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 540 KB Output is correct
22 Correct 87 ms 13940 KB Output is correct
23 Correct 112 ms 13544 KB Output is correct
24 Correct 112 ms 10024 KB Output is correct
25 Correct 164 ms 13940 KB Output is correct
26 Correct 130 ms 13892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 113 ms 12860 KB Output is correct
12 Correct 80 ms 9120 KB Output is correct
13 Correct 71 ms 11148 KB Output is correct
14 Correct 137 ms 13776 KB Output is correct
15 Correct 129 ms 13800 KB Output is correct
16 Correct 110 ms 13676 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 300 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 540 KB Output is correct
22 Correct 87 ms 13940 KB Output is correct
23 Correct 112 ms 13544 KB Output is correct
24 Correct 112 ms 10024 KB Output is correct
25 Correct 164 ms 13940 KB Output is correct
26 Correct 130 ms 13892 KB Output is correct
27 Correct 1 ms 212 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 5 ms 688 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 1 ms 316 KB Output is correct
34 Correct 95 ms 13832 KB Output is correct
35 Correct 118 ms 13516 KB Output is correct
36 Correct 135 ms 14388 KB Output is correct
37 Correct 194 ms 14480 KB Output is correct
38 Correct 166 ms 14072 KB Output is correct
39 Correct 86 ms 8704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 113 ms 12860 KB Output is correct
12 Correct 80 ms 9120 KB Output is correct
13 Correct 71 ms 11148 KB Output is correct
14 Correct 137 ms 13776 KB Output is correct
15 Correct 129 ms 13800 KB Output is correct
16 Correct 110 ms 13676 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 300 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 2 ms 540 KB Output is correct
22 Correct 87 ms 13940 KB Output is correct
23 Correct 112 ms 13544 KB Output is correct
24 Correct 112 ms 10024 KB Output is correct
25 Correct 164 ms 13940 KB Output is correct
26 Correct 130 ms 13892 KB Output is correct
27 Correct 1 ms 212 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 5 ms 688 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 1 ms 316 KB Output is correct
34 Correct 95 ms 13832 KB Output is correct
35 Correct 118 ms 13516 KB Output is correct
36 Correct 135 ms 14388 KB Output is correct
37 Correct 194 ms 14480 KB Output is correct
38 Correct 166 ms 14072 KB Output is correct
39 Correct 86 ms 8704 KB Output is correct
40 Correct 3 ms 628 KB Output is correct
41 Correct 3 ms 696 KB Output is correct
42 Correct 3 ms 684 KB Output is correct
43 Correct 6 ms 596 KB Output is correct
44 Correct 128 ms 14840 KB Output is correct
45 Correct 193 ms 14856 KB Output is correct
46 Correct 178 ms 14832 KB Output is correct
47 Correct 227 ms 14840 KB Output is correct
48 Correct 159 ms 14732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 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 0 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 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 5 ms 640 KB Output is correct
27 Correct 5 ms 648 KB Output is correct
28 Correct 5 ms 596 KB Output is correct
29 Correct 6 ms 596 KB Output is correct
30 Correct 3 ms 468 KB Output is correct
31 Correct 4 ms 596 KB Output is correct
32 Correct 5 ms 644 KB Output is correct
33 Correct 6 ms 596 KB Output is correct
34 Correct 7 ms 644 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 3 ms 596 KB Output is correct
38 Correct 4 ms 596 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 113 ms 12860 KB Output is correct
51 Correct 80 ms 9120 KB Output is correct
52 Correct 71 ms 11148 KB Output is correct
53 Correct 137 ms 13776 KB Output is correct
54 Correct 129 ms 13800 KB Output is correct
55 Correct 110 ms 13676 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 0 ms 300 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 2 ms 540 KB Output is correct
61 Correct 87 ms 13940 KB Output is correct
62 Correct 112 ms 13544 KB Output is correct
63 Correct 112 ms 10024 KB Output is correct
64 Correct 164 ms 13940 KB Output is correct
65 Correct 130 ms 13892 KB Output is correct
66 Correct 1 ms 212 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 5 ms 688 KB Output is correct
71 Correct 2 ms 340 KB Output is correct
72 Correct 1 ms 316 KB Output is correct
73 Correct 95 ms 13832 KB Output is correct
74 Correct 118 ms 13516 KB Output is correct
75 Correct 135 ms 14388 KB Output is correct
76 Correct 194 ms 14480 KB Output is correct
77 Correct 166 ms 14072 KB Output is correct
78 Correct 86 ms 8704 KB Output is correct
79 Correct 3 ms 628 KB Output is correct
80 Correct 3 ms 696 KB Output is correct
81 Correct 3 ms 684 KB Output is correct
82 Correct 6 ms 596 KB Output is correct
83 Correct 128 ms 14840 KB Output is correct
84 Correct 193 ms 14856 KB Output is correct
85 Correct 178 ms 14832 KB Output is correct
86 Correct 227 ms 14840 KB Output is correct
87 Correct 159 ms 14732 KB Output is correct
88 Correct 169 ms 16532 KB Output is correct
89 Correct 220 ms 16508 KB Output is correct
90 Correct 184 ms 16548 KB Output is correct
91 Correct 260 ms 16636 KB Output is correct
92 Correct 146 ms 15100 KB Output is correct
93 Correct 239 ms 15588 KB Output is correct
94 Correct 218 ms 15240 KB Output is correct
95 Correct 208 ms 16312 KB Output is correct
96 Correct 245 ms 16460 KB Output is correct
97 Correct 198 ms 16528 KB Output is correct
98 Correct 135 ms 15304 KB Output is correct
99 Correct 174 ms 15380 KB Output is correct