답안 #561001

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
561001 2022-05-12T07:32:51 Z two_sides Team Contest (JOI22_team) C++17
100 / 100
635 ms 26984 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 150005;

int x[N][3];
set<pair<int, int>> s[3];

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++) {
            cin >> x[i][j];
            s[j].emplace(x[i][j], i);
        }
    while (s[0].size()) {
        int p = -1;
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                int q = s[j].rbegin()->second;
                if (x[q][k] == s[k].rbegin()->first)
                    p = q;
            }
        if (p < 0) {
            cout << s[0].rbegin()->first
            + s[1].rbegin()->first
            + s[2].rbegin()->first;
            return 0;
        }
        for (int j = 0; j < 3; j++)
            s[j].erase(make_pair(x[p][j], p));
    }
    cout << -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 1 ms 212 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 336 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 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 1 ms 212 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 336 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 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 5 ms 980 KB Output is correct
27 Correct 6 ms 976 KB Output is correct
28 Correct 6 ms 980 KB Output is correct
29 Correct 5 ms 980 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 4 ms 852 KB Output is correct
32 Correct 6 ms 884 KB Output is correct
33 Correct 4 ms 980 KB Output is correct
34 Correct 4 ms 980 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 4 ms 980 KB Output is correct
38 Correct 4 ms 980 KB Output is correct
39 Correct 2 ms 596 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 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 1 ms 212 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 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 167 ms 23740 KB Output is correct
12 Correct 137 ms 15948 KB Output is correct
13 Correct 126 ms 19756 KB Output is correct
14 Correct 214 ms 23940 KB Output is correct
15 Correct 175 ms 23628 KB Output is correct
16 Correct 166 ms 23744 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 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 1 ms 212 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 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 167 ms 23740 KB Output is correct
12 Correct 137 ms 15948 KB Output is correct
13 Correct 126 ms 19756 KB Output is correct
14 Correct 214 ms 23940 KB Output is correct
15 Correct 175 ms 23628 KB Output is correct
16 Correct 166 ms 23744 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 212 ms 23880 KB Output is correct
23 Correct 224 ms 23488 KB Output is correct
24 Correct 191 ms 17480 KB Output is correct
25 Correct 318 ms 24204 KB Output is correct
26 Correct 214 ms 24036 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 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 1 ms 212 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 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 167 ms 23740 KB Output is correct
12 Correct 137 ms 15948 KB Output is correct
13 Correct 126 ms 19756 KB Output is correct
14 Correct 214 ms 23940 KB Output is correct
15 Correct 175 ms 23628 KB Output is correct
16 Correct 166 ms 23744 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 212 ms 23880 KB Output is correct
23 Correct 224 ms 23488 KB Output is correct
24 Correct 191 ms 17480 KB Output is correct
25 Correct 318 ms 24204 KB Output is correct
26 Correct 214 ms 24036 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 5 ms 852 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 271 ms 23452 KB Output is correct
35 Correct 291 ms 21856 KB Output is correct
36 Correct 387 ms 24380 KB Output is correct
37 Correct 390 ms 24648 KB Output is correct
38 Correct 277 ms 23820 KB Output is correct
39 Correct 118 ms 14664 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 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 1 ms 212 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 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 167 ms 23740 KB Output is correct
12 Correct 137 ms 15948 KB Output is correct
13 Correct 126 ms 19756 KB Output is correct
14 Correct 214 ms 23940 KB Output is correct
15 Correct 175 ms 23628 KB Output is correct
16 Correct 166 ms 23744 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 212 ms 23880 KB Output is correct
23 Correct 224 ms 23488 KB Output is correct
24 Correct 191 ms 17480 KB Output is correct
25 Correct 318 ms 24204 KB Output is correct
26 Correct 214 ms 24036 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 5 ms 852 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 271 ms 23452 KB Output is correct
35 Correct 291 ms 21856 KB Output is correct
36 Correct 387 ms 24380 KB Output is correct
37 Correct 390 ms 24648 KB Output is correct
38 Correct 277 ms 23820 KB Output is correct
39 Correct 118 ms 14664 KB Output is correct
40 Correct 4 ms 716 KB Output is correct
41 Correct 5 ms 980 KB Output is correct
42 Correct 3 ms 852 KB Output is correct
43 Correct 4 ms 984 KB Output is correct
44 Correct 437 ms 25328 KB Output is correct
45 Correct 549 ms 25144 KB Output is correct
46 Correct 514 ms 24668 KB Output is correct
47 Correct 635 ms 25296 KB Output is correct
48 Correct 329 ms 25064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 1 ms 212 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 336 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 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 5 ms 980 KB Output is correct
27 Correct 6 ms 976 KB Output is correct
28 Correct 6 ms 980 KB Output is correct
29 Correct 5 ms 980 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 4 ms 852 KB Output is correct
32 Correct 6 ms 884 KB Output is correct
33 Correct 4 ms 980 KB Output is correct
34 Correct 4 ms 980 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 4 ms 980 KB Output is correct
38 Correct 4 ms 980 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 1 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 1 ms 212 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 167 ms 23740 KB Output is correct
51 Correct 137 ms 15948 KB Output is correct
52 Correct 126 ms 19756 KB Output is correct
53 Correct 214 ms 23940 KB Output is correct
54 Correct 175 ms 23628 KB Output is correct
55 Correct 166 ms 23744 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 1 ms 332 KB Output is correct
60 Correct 2 ms 596 KB Output is correct
61 Correct 212 ms 23880 KB Output is correct
62 Correct 224 ms 23488 KB Output is correct
63 Correct 191 ms 17480 KB Output is correct
64 Correct 318 ms 24204 KB Output is correct
65 Correct 214 ms 24036 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 5 ms 852 KB Output is correct
71 Correct 1 ms 468 KB Output is correct
72 Correct 2 ms 468 KB Output is correct
73 Correct 271 ms 23452 KB Output is correct
74 Correct 291 ms 21856 KB Output is correct
75 Correct 387 ms 24380 KB Output is correct
76 Correct 390 ms 24648 KB Output is correct
77 Correct 277 ms 23820 KB Output is correct
78 Correct 118 ms 14664 KB Output is correct
79 Correct 4 ms 716 KB Output is correct
80 Correct 5 ms 980 KB Output is correct
81 Correct 3 ms 852 KB Output is correct
82 Correct 4 ms 984 KB Output is correct
83 Correct 437 ms 25328 KB Output is correct
84 Correct 549 ms 25144 KB Output is correct
85 Correct 514 ms 24668 KB Output is correct
86 Correct 635 ms 25296 KB Output is correct
87 Correct 329 ms 25064 KB Output is correct
88 Correct 437 ms 25636 KB Output is correct
89 Correct 534 ms 25284 KB Output is correct
90 Correct 443 ms 26952 KB Output is correct
91 Correct 554 ms 24784 KB Output is correct
92 Correct 485 ms 24816 KB Output is correct
93 Correct 605 ms 25960 KB Output is correct
94 Correct 541 ms 25812 KB Output is correct
95 Correct 353 ms 26984 KB Output is correct
96 Correct 276 ms 26684 KB Output is correct
97 Correct 175 ms 25764 KB Output is correct
98 Correct 154 ms 25628 KB Output is correct
99 Correct 175 ms 25676 KB Output is correct