Submission #580572

# Submission time Handle Problem Language Result Execution time Memory
580572 2022-06-21T12:46:04 Z CyberSleeper Team Contest (JOI22_team) C++17
100 / 100
93 ms 14836 KB
#include <bits/stdc++.h>
#define fastio      ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define debug(x)    cout << "Line " << __LINE__ << ", " << #x << " is " << x << endl
#define all(x)      x.begin(), x.end()
#define fi          first
#define se          second
#define mp          make_pair
#define pb          push_back
#define ll          long long
#define ull         unsigned long long
#define pll         pair<ll, ll>
#define pii         pair<ll, ll>
#define ld          long double
#define nl          '\n'
#define tb          '\t'
#define sp          ' '
#define sqr(x)      (x)*(x)
#define arr3        array<ll, 3>
using namespace std;

const ll MX=150002, MOD=1000000007, BLOCK=160, INF=1e9+7, LG=62;
const ll INFF=1000000000000000004;
const ld ERR=1e-6, pi=3.14159265358979323846;

ll N, X[MX], Y[MX], Z[MX];
pll A[MX], B[MX], C[MX];

int main(){
    fastio;
    cin >> N;
    for(ll i=0; i<N; i++){
        cin >> X[i] >> Y[i] >> Z[i];
        A[i]={X[i], i};
        B[i]={Y[i], i};
        C[i]={Z[i], i};
    }
    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);
    ll px=N-1, py=N-1, pz=N-1;
    while(px>=0 && py>=0 && pz>=0){
        ll x=A[px].se, y=B[py].se, z=C[pz].se;
        if(X[x]<=X[y]){py--; continue;}
        if(X[x]<=X[z]){pz--; continue;}
        if(Y[y]<=Y[x]){px--; continue;}
        if(Y[y]<=Y[z]){pz--; continue;}
        if(Z[z]<=Z[x]){px--; continue;}
        if(Z[z]<=Z[y]){py--; continue;}
        cout << X[x]+Y[y]+Z[z] << nl;
        return 0;
    }
    cout << "-1\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 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 1 ms 340 KB Output is correct
12 Correct 0 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 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 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 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 1 ms 340 KB Output is correct
12 Correct 0 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 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 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 328 KB Output is correct
26 Correct 2 ms 720 KB Output is correct
27 Correct 2 ms 724 KB Output is correct
28 Correct 3 ms 724 KB Output is correct
29 Correct 3 ms 724 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 596 KB Output is correct
32 Correct 3 ms 596 KB Output is correct
33 Correct 2 ms 724 KB Output is correct
34 Correct 3 ms 724 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 2 ms 596 KB Output is correct
38 Correct 4 ms 600 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 1 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 1 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 65 ms 11680 KB Output is correct
12 Correct 46 ms 7956 KB Output is correct
13 Correct 44 ms 9696 KB Output is correct
14 Correct 68 ms 11756 KB Output is correct
15 Correct 60 ms 11760 KB Output is correct
16 Correct 35 ms 11748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 1 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 1 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 65 ms 11680 KB Output is correct
12 Correct 46 ms 7956 KB Output is correct
13 Correct 44 ms 9696 KB Output is correct
14 Correct 68 ms 11756 KB Output is correct
15 Correct 60 ms 11760 KB Output is correct
16 Correct 35 ms 11748 KB Output is correct
17 Correct 1 ms 332 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 2 ms 468 KB Output is correct
22 Correct 78 ms 12004 KB Output is correct
23 Correct 67 ms 11520 KB Output is correct
24 Correct 53 ms 8784 KB Output is correct
25 Correct 73 ms 12008 KB Output is correct
26 Correct 65 ms 11856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 1 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 1 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 65 ms 11680 KB Output is correct
12 Correct 46 ms 7956 KB Output is correct
13 Correct 44 ms 9696 KB Output is correct
14 Correct 68 ms 11756 KB Output is correct
15 Correct 60 ms 11760 KB Output is correct
16 Correct 35 ms 11748 KB Output is correct
17 Correct 1 ms 332 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 2 ms 468 KB Output is correct
22 Correct 78 ms 12004 KB Output is correct
23 Correct 67 ms 11520 KB Output is correct
24 Correct 53 ms 8784 KB Output is correct
25 Correct 73 ms 12008 KB Output is correct
26 Correct 65 ms 11856 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 3 ms 596 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 70 ms 11920 KB Output is correct
35 Correct 68 ms 11308 KB Output is correct
36 Correct 79 ms 12376 KB Output is correct
37 Correct 81 ms 12436 KB Output is correct
38 Correct 61 ms 12180 KB Output is correct
39 Correct 28 ms 7628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 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 1 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 1 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 65 ms 11680 KB Output is correct
12 Correct 46 ms 7956 KB Output is correct
13 Correct 44 ms 9696 KB Output is correct
14 Correct 68 ms 11756 KB Output is correct
15 Correct 60 ms 11760 KB Output is correct
16 Correct 35 ms 11748 KB Output is correct
17 Correct 1 ms 332 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 2 ms 468 KB Output is correct
22 Correct 78 ms 12004 KB Output is correct
23 Correct 67 ms 11520 KB Output is correct
24 Correct 53 ms 8784 KB Output is correct
25 Correct 73 ms 12008 KB Output is correct
26 Correct 65 ms 11856 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 3 ms 596 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 70 ms 11920 KB Output is correct
35 Correct 68 ms 11308 KB Output is correct
36 Correct 79 ms 12376 KB Output is correct
37 Correct 81 ms 12436 KB Output is correct
38 Correct 61 ms 12180 KB Output is correct
39 Correct 28 ms 7628 KB Output is correct
40 Correct 2 ms 468 KB Output is correct
41 Correct 2 ms 596 KB Output is correct
42 Correct 2 ms 596 KB Output is correct
43 Correct 2 ms 592 KB Output is correct
44 Correct 85 ms 12948 KB Output is correct
45 Correct 83 ms 12876 KB Output is correct
46 Correct 79 ms 12848 KB Output is correct
47 Correct 79 ms 13024 KB Output is correct
48 Correct 76 ms 12864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 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 1 ms 340 KB Output is correct
12 Correct 0 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 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 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 328 KB Output is correct
26 Correct 2 ms 720 KB Output is correct
27 Correct 2 ms 724 KB Output is correct
28 Correct 3 ms 724 KB Output is correct
29 Correct 3 ms 724 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 596 KB Output is correct
32 Correct 3 ms 596 KB Output is correct
33 Correct 2 ms 724 KB Output is correct
34 Correct 3 ms 724 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 2 ms 596 KB Output is correct
38 Correct 4 ms 600 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 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 1 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 1 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 65 ms 11680 KB Output is correct
51 Correct 46 ms 7956 KB Output is correct
52 Correct 44 ms 9696 KB Output is correct
53 Correct 68 ms 11756 KB Output is correct
54 Correct 60 ms 11760 KB Output is correct
55 Correct 35 ms 11748 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 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 468 KB Output is correct
61 Correct 78 ms 12004 KB Output is correct
62 Correct 67 ms 11520 KB Output is correct
63 Correct 53 ms 8784 KB Output is correct
64 Correct 73 ms 12008 KB Output is correct
65 Correct 65 ms 11856 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 3 ms 596 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 70 ms 11920 KB Output is correct
74 Correct 68 ms 11308 KB Output is correct
75 Correct 79 ms 12376 KB Output is correct
76 Correct 81 ms 12436 KB Output is correct
77 Correct 61 ms 12180 KB Output is correct
78 Correct 28 ms 7628 KB Output is correct
79 Correct 2 ms 468 KB Output is correct
80 Correct 2 ms 596 KB Output is correct
81 Correct 2 ms 596 KB Output is correct
82 Correct 2 ms 592 KB Output is correct
83 Correct 85 ms 12948 KB Output is correct
84 Correct 83 ms 12876 KB Output is correct
85 Correct 79 ms 12848 KB Output is correct
86 Correct 79 ms 13024 KB Output is correct
87 Correct 76 ms 12864 KB Output is correct
88 Correct 89 ms 14688 KB Output is correct
89 Correct 87 ms 14680 KB Output is correct
90 Correct 85 ms 14688 KB Output is correct
91 Correct 93 ms 14644 KB Output is correct
92 Correct 86 ms 13292 KB Output is correct
93 Correct 86 ms 13656 KB Output is correct
94 Correct 82 ms 13484 KB Output is correct
95 Correct 78 ms 14544 KB Output is correct
96 Correct 93 ms 14736 KB Output is correct
97 Correct 56 ms 14836 KB Output is correct
98 Correct 47 ms 13400 KB Output is correct
99 Correct 75 ms 13424 KB Output is correct