답안 #945342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
945342 2024-03-13T16:27:17 Z socpite Team Contest (JOI22_team) C++14
100 / 100
379 ms 27468 KB
#include<bits/stdc++.h>
using namespace std;

const int maxn = 150005;

int A[maxn], B[maxn], C[maxn];
int n;
set<pair<int, int>> sa, sb, sc;

bool check(int id){
    return int(A[id] == sa.rbegin()->first) + int(B[id] == sb.rbegin()->first) + int(C[id] == sc.rbegin()->first) < 2; 
}

void rmv(int id){
    sa.erase({A[id], id});
    sb.erase({B[id], id});
    sc.erase({C[id], id});
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> A[i] >> B[i] >> C[i];
        sa.insert({A[i], i});
        sb.insert({B[i], i});
        sc.insert({C[i], i});
    }
    while(!sa.empty()){
        if(!check(sa.rbegin()->second)){
            rmv(sa.rbegin()->second);
            continue;
        }
        if(!check(sb.rbegin()->second)){
            rmv(sb.rbegin()->second);
            continue;
        }
        if(!check(sc.rbegin()->second)){
            rmv(sc.rbegin()->second);
            continue;
        }
        break;
    }
    if(sa.empty()){
        cout << "-1";
        return 0;
    }
    cout << sa.rbegin()->first + sb.rbegin()->first + sc.rbegin()->first;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 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 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 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 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 468 KB Output is correct
26 Correct 4 ms 1112 KB Output is correct
27 Correct 4 ms 1116 KB Output is correct
28 Correct 5 ms 988 KB Output is correct
29 Correct 4 ms 996 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 3 ms 1116 KB Output is correct
32 Correct 4 ms 1116 KB Output is correct
33 Correct 4 ms 1116 KB Output is correct
34 Correct 3 ms 1116 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
37 Correct 2 ms 1112 KB Output is correct
38 Correct 3 ms 1116 KB Output is correct
39 Correct 2 ms 732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 352 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 117 ms 24144 KB Output is correct
12 Correct 106 ms 16468 KB Output is correct
13 Correct 83 ms 19796 KB Output is correct
14 Correct 162 ms 24148 KB Output is correct
15 Correct 133 ms 24064 KB Output is correct
16 Correct 107 ms 24060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 352 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 117 ms 24144 KB Output is correct
12 Correct 106 ms 16468 KB Output is correct
13 Correct 83 ms 19796 KB Output is correct
14 Correct 162 ms 24148 KB Output is correct
15 Correct 133 ms 24064 KB Output is correct
16 Correct 107 ms 24060 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 147 ms 24224 KB Output is correct
23 Correct 145 ms 24024 KB Output is correct
24 Correct 123 ms 17616 KB Output is correct
25 Correct 203 ms 24332 KB Output is correct
26 Correct 129 ms 24408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 352 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 117 ms 24144 KB Output is correct
12 Correct 106 ms 16468 KB Output is correct
13 Correct 83 ms 19796 KB Output is correct
14 Correct 162 ms 24148 KB Output is correct
15 Correct 133 ms 24064 KB Output is correct
16 Correct 107 ms 24060 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 147 ms 24224 KB Output is correct
23 Correct 145 ms 24024 KB Output is correct
24 Correct 123 ms 17616 KB Output is correct
25 Correct 203 ms 24332 KB Output is correct
26 Correct 129 ms 24408 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 1116 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 199 ms 23632 KB Output is correct
35 Correct 239 ms 22712 KB Output is correct
36 Correct 327 ms 24632 KB Output is correct
37 Correct 280 ms 24916 KB Output is correct
38 Correct 158 ms 24200 KB Output is correct
39 Correct 69 ms 14932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 352 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 117 ms 24144 KB Output is correct
12 Correct 106 ms 16468 KB Output is correct
13 Correct 83 ms 19796 KB Output is correct
14 Correct 162 ms 24148 KB Output is correct
15 Correct 133 ms 24064 KB Output is correct
16 Correct 107 ms 24060 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 147 ms 24224 KB Output is correct
23 Correct 145 ms 24024 KB Output is correct
24 Correct 123 ms 17616 KB Output is correct
25 Correct 203 ms 24332 KB Output is correct
26 Correct 129 ms 24408 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 1116 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 199 ms 23632 KB Output is correct
35 Correct 239 ms 22712 KB Output is correct
36 Correct 327 ms 24632 KB Output is correct
37 Correct 280 ms 24916 KB Output is correct
38 Correct 158 ms 24200 KB Output is correct
39 Correct 69 ms 14932 KB Output is correct
40 Correct 3 ms 860 KB Output is correct
41 Correct 3 ms 1116 KB Output is correct
42 Correct 2 ms 1116 KB Output is correct
43 Correct 3 ms 1116 KB Output is correct
44 Correct 233 ms 25408 KB Output is correct
45 Correct 299 ms 25424 KB Output is correct
46 Correct 277 ms 25292 KB Output is correct
47 Correct 379 ms 25472 KB Output is correct
48 Correct 176 ms 25168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 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 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 468 KB Output is correct
26 Correct 4 ms 1112 KB Output is correct
27 Correct 4 ms 1116 KB Output is correct
28 Correct 5 ms 988 KB Output is correct
29 Correct 4 ms 996 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 3 ms 1116 KB Output is correct
32 Correct 4 ms 1116 KB Output is correct
33 Correct 4 ms 1116 KB Output is correct
34 Correct 3 ms 1116 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
37 Correct 2 ms 1112 KB Output is correct
38 Correct 3 ms 1116 KB Output is correct
39 Correct 2 ms 732 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 352 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 117 ms 24144 KB Output is correct
51 Correct 106 ms 16468 KB Output is correct
52 Correct 83 ms 19796 KB Output is correct
53 Correct 162 ms 24148 KB Output is correct
54 Correct 133 ms 24064 KB Output is correct
55 Correct 107 ms 24060 KB Output is correct
56 Correct 1 ms 344 KB Output is correct
57 Correct 0 ms 600 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 2 ms 604 KB Output is correct
61 Correct 147 ms 24224 KB Output is correct
62 Correct 145 ms 24024 KB Output is correct
63 Correct 123 ms 17616 KB Output is correct
64 Correct 203 ms 24332 KB Output is correct
65 Correct 129 ms 24408 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 1116 KB Output is correct
71 Correct 1 ms 604 KB Output is correct
72 Correct 1 ms 604 KB Output is correct
73 Correct 199 ms 23632 KB Output is correct
74 Correct 239 ms 22712 KB Output is correct
75 Correct 327 ms 24632 KB Output is correct
76 Correct 280 ms 24916 KB Output is correct
77 Correct 158 ms 24200 KB Output is correct
78 Correct 69 ms 14932 KB Output is correct
79 Correct 3 ms 860 KB Output is correct
80 Correct 3 ms 1116 KB Output is correct
81 Correct 2 ms 1116 KB Output is correct
82 Correct 3 ms 1116 KB Output is correct
83 Correct 233 ms 25408 KB Output is correct
84 Correct 299 ms 25424 KB Output is correct
85 Correct 277 ms 25292 KB Output is correct
86 Correct 379 ms 25472 KB Output is correct
87 Correct 176 ms 25168 KB Output is correct
88 Correct 278 ms 27216 KB Output is correct
89 Correct 257 ms 27204 KB Output is correct
90 Correct 264 ms 27468 KB Output is correct
91 Correct 271 ms 27144 KB Output is correct
92 Correct 246 ms 25680 KB Output is correct
93 Correct 276 ms 26100 KB Output is correct
94 Correct 335 ms 25688 KB Output is correct
95 Correct 201 ms 27296 KB Output is correct
96 Correct 157 ms 27220 KB Output is correct
97 Correct 122 ms 27220 KB Output is correct
98 Correct 106 ms 25824 KB Output is correct
99 Correct 122 ms 25680 KB Output is correct