Submission #713899

# Submission time Handle Problem Language Result Execution time Memory
713899 2023-03-23T07:53:24 Z becaido Team Contest (JOI22_team) C++17
100 / 100
101 ms 5776 KB
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout(T t, U...u) {cout << t << (sizeof... (u) ? ", " : ""), dout (u...);}
#else
#define debug(...) 7122
#endif

#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second

const int SIZE = 1.5e5 + 5;

int n;
array<int, 3> a[SIZE];
pair<int, int> p[3][SIZE];
bool is[SIZE];

void solve() {
    cin >> n;
    FOR (i, 1, n) FOR (j, 0, 2) cin >> a[i][j];
    sort(a + 1, a + n + 1);
    FOR (j, 1, n) FOR (i, 0, 2) {
        p[i][j].F = a[j][i];
        p[i][j].S = j;
    }
    FOR (i, 0, 2) sort(p[i] + 1, p[i] + n + 1, greater<pair<int, int>>());
    for (int i[3] = {1, 1, 1};;) {
        FOR (j, 0, 2) while (i[j] <= n && is[p[j][i[j]].S]) i[j]++;
        if (*max_element(i, i + 3) > n) break;
        int x = p[0][i[0]].S, y = p[1][i[1]].S, z = p[2][i[2]].S;
        debug(x, y, z);
        if (a[x][1] >= a[y][1] || a[x][2] >= a[z][2]) {is[x] = 1; continue;}
        if (a[y][0] >= a[x][0] || a[y][2] >= a[z][2]) {is[y] = 1; continue;}
        if (a[z][0] >= a[x][0] || a[z][1] >= a[y][1]) {is[z] = 1; continue;}
        cout << a[x][0] + a[y][1] + a[z][2] << '\n';
        return;
    }
    cout << "-1\n";
}

int main() {
    Waimai;
    solve();
}

Compilation message

team.cpp: In function 'void solve()':
team.cpp:11:20: warning: statement has no effect [-Wunused-value]
   11 | #define debug(...) 7122
      |                    ^~~~
team.cpp:41:9: note: in expansion of macro 'debug'
   41 |         debug(x, y, z);
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 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 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 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 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 3 ms 480 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 3 ms 468 KB Output is correct
33 Correct 2 ms 472 KB Output is correct
34 Correct 3 ms 468 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 2 ms 464 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 58 ms 5572 KB Output is correct
12 Correct 38 ms 3876 KB Output is correct
13 Correct 42 ms 4684 KB Output is correct
14 Correct 61 ms 5716 KB Output is correct
15 Correct 64 ms 5724 KB Output is correct
16 Correct 53 ms 5676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 58 ms 5572 KB Output is correct
12 Correct 38 ms 3876 KB Output is correct
13 Correct 42 ms 4684 KB Output is correct
14 Correct 61 ms 5716 KB Output is correct
15 Correct 64 ms 5724 KB Output is correct
16 Correct 53 ms 5676 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 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 2 ms 340 KB Output is correct
22 Correct 66 ms 5540 KB Output is correct
23 Correct 59 ms 5428 KB Output is correct
24 Correct 45 ms 4172 KB Output is correct
25 Correct 81 ms 5776 KB Output is correct
26 Correct 55 ms 5672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 58 ms 5572 KB Output is correct
12 Correct 38 ms 3876 KB Output is correct
13 Correct 42 ms 4684 KB Output is correct
14 Correct 61 ms 5716 KB Output is correct
15 Correct 64 ms 5724 KB Output is correct
16 Correct 53 ms 5676 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 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 2 ms 340 KB Output is correct
22 Correct 66 ms 5540 KB Output is correct
23 Correct 59 ms 5428 KB Output is correct
24 Correct 45 ms 4172 KB Output is correct
25 Correct 81 ms 5776 KB Output is correct
26 Correct 55 ms 5672 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 360 KB Output is correct
34 Correct 87 ms 5356 KB Output is correct
35 Correct 74 ms 5240 KB Output is correct
36 Correct 76 ms 5716 KB Output is correct
37 Correct 72 ms 5640 KB Output is correct
38 Correct 64 ms 5620 KB Output is correct
39 Correct 32 ms 3500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 58 ms 5572 KB Output is correct
12 Correct 38 ms 3876 KB Output is correct
13 Correct 42 ms 4684 KB Output is correct
14 Correct 61 ms 5716 KB Output is correct
15 Correct 64 ms 5724 KB Output is correct
16 Correct 53 ms 5676 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 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 2 ms 340 KB Output is correct
22 Correct 66 ms 5540 KB Output is correct
23 Correct 59 ms 5428 KB Output is correct
24 Correct 45 ms 4172 KB Output is correct
25 Correct 81 ms 5776 KB Output is correct
26 Correct 55 ms 5672 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 360 KB Output is correct
34 Correct 87 ms 5356 KB Output is correct
35 Correct 74 ms 5240 KB Output is correct
36 Correct 76 ms 5716 KB Output is correct
37 Correct 72 ms 5640 KB Output is correct
38 Correct 64 ms 5620 KB Output is correct
39 Correct 32 ms 3500 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 2 ms 468 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 3 ms 468 KB Output is correct
44 Correct 80 ms 5532 KB Output is correct
45 Correct 81 ms 5660 KB Output is correct
46 Correct 83 ms 5720 KB Output is correct
47 Correct 85 ms 5728 KB Output is correct
48 Correct 72 ms 5720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 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 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 3 ms 480 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 3 ms 468 KB Output is correct
33 Correct 2 ms 472 KB Output is correct
34 Correct 3 ms 468 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 2 ms 464 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 58 ms 5572 KB Output is correct
51 Correct 38 ms 3876 KB Output is correct
52 Correct 42 ms 4684 KB Output is correct
53 Correct 61 ms 5716 KB Output is correct
54 Correct 64 ms 5724 KB Output is correct
55 Correct 53 ms 5676 KB Output is correct
56 Correct 1 ms 340 KB Output is correct
57 Correct 0 ms 340 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 2 ms 340 KB Output is correct
61 Correct 66 ms 5540 KB Output is correct
62 Correct 59 ms 5428 KB Output is correct
63 Correct 45 ms 4172 KB Output is correct
64 Correct 81 ms 5776 KB Output is correct
65 Correct 55 ms 5672 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 0 ms 340 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 0 ms 340 KB Output is correct
70 Correct 2 ms 468 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 360 KB Output is correct
73 Correct 87 ms 5356 KB Output is correct
74 Correct 74 ms 5240 KB Output is correct
75 Correct 76 ms 5716 KB Output is correct
76 Correct 72 ms 5640 KB Output is correct
77 Correct 64 ms 5620 KB Output is correct
78 Correct 32 ms 3500 KB Output is correct
79 Correct 2 ms 340 KB Output is correct
80 Correct 2 ms 468 KB Output is correct
81 Correct 2 ms 468 KB Output is correct
82 Correct 3 ms 468 KB Output is correct
83 Correct 80 ms 5532 KB Output is correct
84 Correct 81 ms 5660 KB Output is correct
85 Correct 83 ms 5720 KB Output is correct
86 Correct 85 ms 5728 KB Output is correct
87 Correct 72 ms 5720 KB Output is correct
88 Correct 82 ms 5520 KB Output is correct
89 Correct 93 ms 5720 KB Output is correct
90 Correct 85 ms 5720 KB Output is correct
91 Correct 92 ms 5656 KB Output is correct
92 Correct 83 ms 5660 KB Output is correct
93 Correct 95 ms 5732 KB Output is correct
94 Correct 101 ms 5712 KB Output is correct
95 Correct 82 ms 5720 KB Output is correct
96 Correct 64 ms 5720 KB Output is correct
97 Correct 57 ms 5696 KB Output is correct
98 Correct 48 ms 5520 KB Output is correct
99 Correct 73 ms 5728 KB Output is correct