Submission #971643

# Submission time Handle Problem Language Result Execution time Memory
971643 2024-04-29T06:12:12 Z 12345678 Team Contest (JOI22_team) C++17
100 / 100
81 ms 10956 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=2e5+5;

int n, a[nx], b[nx], c[nx], used[nx];
vector<pair<int, int>> x, y, z;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i]>>b[i]>>c[i], x.push_back({a[i], i}), y.push_back({b[i], i}), z.push_back({c[i], i});
    sort(x.begin(), x.end());
    reverse(x.begin(), x.end());
    sort(y.begin(), y.end());
    reverse(y.begin(), y.end());
    sort(z.begin(), z.end());
    reverse(z.begin(), z.end());
    int i=0, j=0, k=0;
    while (i<n&&j<n&&k<n)
    {
        if (used[x[i].second]) i++;
        else if (used[y[j].second]) j++;
        else if (used[z[k].second]) k++;
        else if (b[x[i].second]==b[y[j].second]||c[x[i].second]==c[z[k].second]) used[x[i].second]=1;
        else if (a[x[i].second]==a[y[j].second]||c[y[j].second]==c[z[k].second]) used[y[j].second]=1;
        else if (a[x[i].second]==a[z[k].second]||b[y[j].second]==b[z[k].second]) used[z[k].second]=1;
        else return cout<<x[i].first+y[j].first+z[k].first, 0;
    }
    cout<<-1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2512 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2516 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2512 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2516 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 2 ms 2652 KB Output is correct
27 Correct 2 ms 2652 KB Output is correct
28 Correct 2 ms 2652 KB Output is correct
29 Correct 3 ms 2648 KB Output is correct
30 Correct 2 ms 2624 KB Output is correct
31 Correct 2 ms 2516 KB Output is correct
32 Correct 2 ms 2652 KB Output is correct
33 Correct 2 ms 2656 KB Output is correct
34 Correct 3 ms 2652 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 2 ms 2652 KB Output is correct
38 Correct 2 ms 2652 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 56 ms 7956 KB Output is correct
12 Correct 40 ms 6076 KB Output is correct
13 Correct 41 ms 6840 KB Output is correct
14 Correct 59 ms 8032 KB Output is correct
15 Correct 55 ms 8124 KB Output is correct
16 Correct 40 ms 8124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 56 ms 7956 KB Output is correct
12 Correct 40 ms 6076 KB Output is correct
13 Correct 41 ms 6840 KB Output is correct
14 Correct 59 ms 8032 KB Output is correct
15 Correct 55 ms 8124 KB Output is correct
16 Correct 40 ms 8124 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 69 ms 8272 KB Output is correct
23 Correct 61 ms 8120 KB Output is correct
24 Correct 46 ms 6428 KB Output is correct
25 Correct 68 ms 8632 KB Output is correct
26 Correct 54 ms 8120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 56 ms 7956 KB Output is correct
12 Correct 40 ms 6076 KB Output is correct
13 Correct 41 ms 6840 KB Output is correct
14 Correct 59 ms 8032 KB Output is correct
15 Correct 55 ms 8124 KB Output is correct
16 Correct 40 ms 8124 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 69 ms 8272 KB Output is correct
23 Correct 61 ms 8120 KB Output is correct
24 Correct 46 ms 6428 KB Output is correct
25 Correct 68 ms 8632 KB Output is correct
26 Correct 54 ms 8120 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 2 ms 2652 KB Output is correct
32 Correct 1 ms 2408 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 63 ms 8688 KB Output is correct
35 Correct 61 ms 8636 KB Output is correct
36 Correct 70 ms 8640 KB Output is correct
37 Correct 70 ms 8888 KB Output is correct
38 Correct 61 ms 8688 KB Output is correct
39 Correct 27 ms 6076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 56 ms 7956 KB Output is correct
12 Correct 40 ms 6076 KB Output is correct
13 Correct 41 ms 6840 KB Output is correct
14 Correct 59 ms 8032 KB Output is correct
15 Correct 55 ms 8124 KB Output is correct
16 Correct 40 ms 8124 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 69 ms 8272 KB Output is correct
23 Correct 61 ms 8120 KB Output is correct
24 Correct 46 ms 6428 KB Output is correct
25 Correct 68 ms 8632 KB Output is correct
26 Correct 54 ms 8120 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 2 ms 2652 KB Output is correct
32 Correct 1 ms 2408 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 63 ms 8688 KB Output is correct
35 Correct 61 ms 8636 KB Output is correct
36 Correct 70 ms 8640 KB Output is correct
37 Correct 70 ms 8888 KB Output is correct
38 Correct 61 ms 8688 KB Output is correct
39 Correct 27 ms 6076 KB Output is correct
40 Correct 2 ms 2848 KB Output is correct
41 Correct 2 ms 2716 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 2 ms 2556 KB Output is correct
44 Correct 70 ms 9104 KB Output is correct
45 Correct 72 ms 9156 KB Output is correct
46 Correct 74 ms 9148 KB Output is correct
47 Correct 71 ms 9112 KB Output is correct
48 Correct 64 ms 9096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2512 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2516 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 2 ms 2652 KB Output is correct
27 Correct 2 ms 2652 KB Output is correct
28 Correct 2 ms 2652 KB Output is correct
29 Correct 3 ms 2648 KB Output is correct
30 Correct 2 ms 2624 KB Output is correct
31 Correct 2 ms 2516 KB Output is correct
32 Correct 2 ms 2652 KB Output is correct
33 Correct 2 ms 2656 KB Output is correct
34 Correct 3 ms 2652 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 2 ms 2652 KB Output is correct
38 Correct 2 ms 2652 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2392 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 0 ms 2396 KB Output is correct
50 Correct 56 ms 7956 KB Output is correct
51 Correct 40 ms 6076 KB Output is correct
52 Correct 41 ms 6840 KB Output is correct
53 Correct 59 ms 8032 KB Output is correct
54 Correct 55 ms 8124 KB Output is correct
55 Correct 40 ms 8124 KB Output is correct
56 Correct 1 ms 2392 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 1 ms 2392 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 69 ms 8272 KB Output is correct
62 Correct 61 ms 8120 KB Output is correct
63 Correct 46 ms 6428 KB Output is correct
64 Correct 68 ms 8632 KB Output is correct
65 Correct 54 ms 8120 KB Output is correct
66 Correct 1 ms 2392 KB Output is correct
67 Correct 1 ms 2396 KB Output is correct
68 Correct 1 ms 2396 KB Output is correct
69 Correct 1 ms 2396 KB Output is correct
70 Correct 2 ms 2652 KB Output is correct
71 Correct 1 ms 2408 KB Output is correct
72 Correct 1 ms 2396 KB Output is correct
73 Correct 63 ms 8688 KB Output is correct
74 Correct 61 ms 8636 KB Output is correct
75 Correct 70 ms 8640 KB Output is correct
76 Correct 70 ms 8888 KB Output is correct
77 Correct 61 ms 8688 KB Output is correct
78 Correct 27 ms 6076 KB Output is correct
79 Correct 2 ms 2848 KB Output is correct
80 Correct 2 ms 2716 KB Output is correct
81 Correct 2 ms 2652 KB Output is correct
82 Correct 2 ms 2556 KB Output is correct
83 Correct 70 ms 9104 KB Output is correct
84 Correct 72 ms 9156 KB Output is correct
85 Correct 74 ms 9148 KB Output is correct
86 Correct 71 ms 9112 KB Output is correct
87 Correct 64 ms 9096 KB Output is correct
88 Correct 71 ms 10724 KB Output is correct
89 Correct 81 ms 10676 KB Output is correct
90 Correct 79 ms 10956 KB Output is correct
91 Correct 81 ms 10644 KB Output is correct
92 Correct 71 ms 9408 KB Output is correct
93 Correct 71 ms 9908 KB Output is correct
94 Correct 73 ms 9668 KB Output is correct
95 Correct 66 ms 10680 KB Output is correct
96 Correct 72 ms 10684 KB Output is correct
97 Correct 47 ms 10768 KB Output is correct
98 Correct 39 ms 9656 KB Output is correct
99 Correct 73 ms 9664 KB Output is correct