Submission #919847

# Submission time Handle Problem Language Result Execution time Memory
919847 2024-02-01T17:50:46 Z Gwynbleidd_ Team Contest (JOI22_team) C++14
100 / 100
710 ms 46672 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    set<vector<int>> x, y, z;
    for (int i = 0; i < n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        x.insert({a, b, c});
        y.insert({b, c, a});
        z.insert({c, a, b});
    }
    int ans = -1;
    while (x.size()) {
        vector<int> a = *x.rbegin(), b = *y.rbegin(), c = *z.rbegin();
        if (a[1] >= b[0]) {
            x.erase(a);
            swap(a[0], a[1]);
            swap(a[1], a[2]);
            y.erase(a);
            swap(a[0], a[1]);
            swap(a[1], a[2]);
            z.erase(a);
        } else if (b[1] >= c[0]) {
            y.erase(b);
            swap(b[0], b[1]);
            swap(b[1], b[2]);
            z.erase(b);
            swap(b[0], b[1]);
            swap(b[1], b[2]);
            x.erase(b);
        } else if (c[1] >= a[0]) {
            z.erase(c);
            swap(c[0], c[1]);
            swap(c[1], c[2]);
            x.erase(c);
            swap(c[0], c[1]);
            swap(c[1], c[2]);
            y.erase(c);
        } else {
            ans = a[0] + b[0] + c[0];
            break;
        }
    }
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 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 344 KB Output is correct
18 Correct 1 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 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 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 344 KB Output is correct
18 Correct 1 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 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 7 ms 1628 KB Output is correct
27 Correct 7 ms 1624 KB Output is correct
28 Correct 7 ms 1624 KB Output is correct
29 Correct 8 ms 1624 KB Output is correct
30 Correct 5 ms 1116 KB Output is correct
31 Correct 5 ms 1368 KB Output is correct
32 Correct 8 ms 1368 KB Output is correct
33 Correct 7 ms 1116 KB Output is correct
34 Correct 7 ms 1628 KB Output is correct
35 Correct 2 ms 600 KB Output is correct
36 Correct 2 ms 600 KB Output is correct
37 Correct 5 ms 1372 KB Output is correct
38 Correct 5 ms 1372 KB Output is correct
39 Correct 3 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 76 ms 1328 KB Output is correct
12 Correct 49 ms 1012 KB Output is correct
13 Correct 57 ms 1108 KB Output is correct
14 Correct 74 ms 1168 KB Output is correct
15 Correct 65 ms 1288 KB Output is correct
16 Correct 61 ms 1104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 76 ms 1328 KB Output is correct
12 Correct 49 ms 1012 KB Output is correct
13 Correct 57 ms 1108 KB Output is correct
14 Correct 74 ms 1168 KB Output is correct
15 Correct 65 ms 1288 KB Output is correct
16 Correct 61 ms 1104 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 500 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 3 ms 856 KB Output is correct
22 Correct 144 ms 3908 KB Output is correct
23 Correct 109 ms 1700 KB Output is correct
24 Correct 79 ms 1356 KB Output is correct
25 Correct 106 ms 1616 KB Output is correct
26 Correct 72 ms 1360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 76 ms 1328 KB Output is correct
12 Correct 49 ms 1012 KB Output is correct
13 Correct 57 ms 1108 KB Output is correct
14 Correct 74 ms 1168 KB Output is correct
15 Correct 65 ms 1288 KB Output is correct
16 Correct 61 ms 1104 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 500 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 3 ms 856 KB Output is correct
22 Correct 144 ms 3908 KB Output is correct
23 Correct 109 ms 1700 KB Output is correct
24 Correct 79 ms 1356 KB Output is correct
25 Correct 106 ms 1616 KB Output is correct
26 Correct 72 ms 1360 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 7 ms 1372 KB Output is correct
32 Correct 2 ms 600 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 499 ms 42024 KB Output is correct
35 Correct 476 ms 37456 KB Output is correct
36 Correct 520 ms 40784 KB Output is correct
37 Correct 419 ms 29384 KB Output is correct
38 Correct 102 ms 1872 KB Output is correct
39 Correct 165 ms 26704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 76 ms 1328 KB Output is correct
12 Correct 49 ms 1012 KB Output is correct
13 Correct 57 ms 1108 KB Output is correct
14 Correct 74 ms 1168 KB Output is correct
15 Correct 65 ms 1288 KB Output is correct
16 Correct 61 ms 1104 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 500 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 3 ms 856 KB Output is correct
22 Correct 144 ms 3908 KB Output is correct
23 Correct 109 ms 1700 KB Output is correct
24 Correct 79 ms 1356 KB Output is correct
25 Correct 106 ms 1616 KB Output is correct
26 Correct 72 ms 1360 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 7 ms 1372 KB Output is correct
32 Correct 2 ms 600 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 499 ms 42024 KB Output is correct
35 Correct 476 ms 37456 KB Output is correct
36 Correct 520 ms 40784 KB Output is correct
37 Correct 419 ms 29384 KB Output is correct
38 Correct 102 ms 1872 KB Output is correct
39 Correct 165 ms 26704 KB Output is correct
40 Correct 5 ms 1112 KB Output is correct
41 Correct 6 ms 1372 KB Output is correct
42 Correct 5 ms 1372 KB Output is correct
43 Correct 5 ms 1368 KB Output is correct
44 Correct 549 ms 44928 KB Output is correct
45 Correct 626 ms 44864 KB Output is correct
46 Correct 662 ms 45240 KB Output is correct
47 Correct 708 ms 44740 KB Output is correct
48 Correct 137 ms 4176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 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 344 KB Output is correct
18 Correct 1 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 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 7 ms 1628 KB Output is correct
27 Correct 7 ms 1624 KB Output is correct
28 Correct 7 ms 1624 KB Output is correct
29 Correct 8 ms 1624 KB Output is correct
30 Correct 5 ms 1116 KB Output is correct
31 Correct 5 ms 1368 KB Output is correct
32 Correct 8 ms 1368 KB Output is correct
33 Correct 7 ms 1116 KB Output is correct
34 Correct 7 ms 1628 KB Output is correct
35 Correct 2 ms 600 KB Output is correct
36 Correct 2 ms 600 KB Output is correct
37 Correct 5 ms 1372 KB Output is correct
38 Correct 5 ms 1372 KB Output is correct
39 Correct 3 ms 856 KB Output is correct
40 Correct 0 ms 600 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 0 ms 344 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 0 ms 344 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 1 ms 344 KB Output is correct
49 Correct 1 ms 344 KB Output is correct
50 Correct 76 ms 1328 KB Output is correct
51 Correct 49 ms 1012 KB Output is correct
52 Correct 57 ms 1108 KB Output is correct
53 Correct 74 ms 1168 KB Output is correct
54 Correct 65 ms 1288 KB Output is correct
55 Correct 61 ms 1104 KB Output is correct
56 Correct 1 ms 344 KB Output is correct
57 Correct 0 ms 344 KB Output is correct
58 Correct 0 ms 500 KB Output is correct
59 Correct 1 ms 344 KB Output is correct
60 Correct 3 ms 856 KB Output is correct
61 Correct 144 ms 3908 KB Output is correct
62 Correct 109 ms 1700 KB Output is correct
63 Correct 79 ms 1356 KB Output is correct
64 Correct 106 ms 1616 KB Output is correct
65 Correct 72 ms 1360 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 1 ms 344 KB Output is correct
68 Correct 1 ms 348 KB Output is correct
69 Correct 1 ms 344 KB Output is correct
70 Correct 7 ms 1372 KB Output is correct
71 Correct 2 ms 600 KB Output is correct
72 Correct 1 ms 604 KB Output is correct
73 Correct 499 ms 42024 KB Output is correct
74 Correct 476 ms 37456 KB Output is correct
75 Correct 520 ms 40784 KB Output is correct
76 Correct 419 ms 29384 KB Output is correct
77 Correct 102 ms 1872 KB Output is correct
78 Correct 165 ms 26704 KB Output is correct
79 Correct 5 ms 1112 KB Output is correct
80 Correct 6 ms 1372 KB Output is correct
81 Correct 5 ms 1372 KB Output is correct
82 Correct 5 ms 1368 KB Output is correct
83 Correct 549 ms 44928 KB Output is correct
84 Correct 626 ms 44864 KB Output is correct
85 Correct 662 ms 45240 KB Output is correct
86 Correct 708 ms 44740 KB Output is correct
87 Correct 137 ms 4176 KB Output is correct
88 Correct 537 ms 46360 KB Output is correct
89 Correct 644 ms 46300 KB Output is correct
90 Correct 528 ms 46320 KB Output is correct
91 Correct 710 ms 46136 KB Output is correct
92 Correct 571 ms 45112 KB Output is correct
93 Correct 679 ms 45296 KB Output is correct
94 Correct 657 ms 45140 KB Output is correct
95 Correct 347 ms 35528 KB Output is correct
96 Correct 456 ms 46672 KB Output is correct
97 Correct 130 ms 4356 KB Output is correct
98 Correct 249 ms 45228 KB Output is correct
99 Correct 267 ms 45396 KB Output is correct