Submission #583679

# Submission time Handle Problem Language Result Execution time Memory
583679 2022-06-26T04:16:10 Z balbit Team Contest (JOI22_team) C++14
100 / 100
164 ms 10264 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define f first
#define s second
#define pii pair<ll, ll>

#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define pb push_back

#define MX(a,b) a = max(a,b)
#define MN(a,b) a = min(a,b)
#define FOR(i,a,b) for (int i = a; i<b; ++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)

#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<"- "<<#__VA_ARGS__<<": ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T && x, S && ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)
#define endl '\n'
#endif // BALBIT

const int maxn = 1.5e5+5;

struct pt{
    int x,y,z;
    void in(){
        cin>>x>>y>>z;
    }
};


vector<array<int, 3> > v[3];

signed main(){
    ios::sync_with_stdio(0), cin.tie(0);

    bug(1,2);

    int n; cin>>n;

    REP(i,n) {
        array<int, 3> a;
        cin>>a[0]>>a[1]>>a[2];
        REP(j,3) v[j].pb(a);
    }

    REP(j,3) {
        sort(ALL(v[j]), [&](array<int, 3> x, array<int, 3> y){return x[j] < y[j];});
    }

    ll re = -1;
    while (SZ(v[0]) && SZ(v[1]) && SZ(v[2])) {
        bool bad = 0;
        REP(j,3) {
            REP(k,3) {
                if (k !=j) {
                    if (v[j].back()[k] >= v[k].back()[k]) {
                        v[j].pop_back(); bad = 1; goto nope;
                    }
                }
            }
        }
        nope:;
        if (!bad) {
            re = 0;
            REP(j,3) {
                re += v[j].back()[j];
            }
            break;
        }
    }

    cout<<re<<endl;



}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 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 316 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 320 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 324 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 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 316 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 320 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 324 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 3 ms 596 KB Output is correct
27 Correct 3 ms 596 KB Output is correct
28 Correct 3 ms 584 KB Output is correct
29 Correct 3 ms 596 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 3 ms 456 KB Output is correct
33 Correct 3 ms 588 KB Output is correct
34 Correct 4 ms 588 KB Output is correct
35 Correct 1 ms 328 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 2 ms 468 KB Output is correct
38 Correct 5 ms 468 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 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 212 KB Output is correct
8 Correct 1 ms 272 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 55 ms 7504 KB Output is correct
12 Correct 43 ms 4484 KB Output is correct
13 Correct 48 ms 5472 KB Output is correct
14 Correct 61 ms 7440 KB Output is correct
15 Correct 54 ms 7460 KB Output is correct
16 Correct 50 ms 7528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 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 212 KB Output is correct
8 Correct 1 ms 272 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 55 ms 7504 KB Output is correct
12 Correct 43 ms 4484 KB Output is correct
13 Correct 48 ms 5472 KB Output is correct
14 Correct 61 ms 7440 KB Output is correct
15 Correct 54 ms 7460 KB Output is correct
16 Correct 50 ms 7528 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 70 ms 7720 KB Output is correct
23 Correct 70 ms 7628 KB Output is correct
24 Correct 55 ms 4956 KB Output is correct
25 Correct 71 ms 7680 KB Output is correct
26 Correct 58 ms 7528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 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 212 KB Output is correct
8 Correct 1 ms 272 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 55 ms 7504 KB Output is correct
12 Correct 43 ms 4484 KB Output is correct
13 Correct 48 ms 5472 KB Output is correct
14 Correct 61 ms 7440 KB Output is correct
15 Correct 54 ms 7460 KB Output is correct
16 Correct 50 ms 7528 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 70 ms 7720 KB Output is correct
23 Correct 70 ms 7628 KB Output is correct
24 Correct 55 ms 4956 KB Output is correct
25 Correct 71 ms 7680 KB Output is correct
26 Correct 58 ms 7528 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 320 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 76 ms 8104 KB Output is correct
35 Correct 67 ms 8136 KB Output is correct
36 Correct 72 ms 8040 KB Output is correct
37 Correct 73 ms 8188 KB Output is correct
38 Correct 60 ms 8116 KB Output is correct
39 Correct 34 ms 4592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 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 212 KB Output is correct
8 Correct 1 ms 272 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 55 ms 7504 KB Output is correct
12 Correct 43 ms 4484 KB Output is correct
13 Correct 48 ms 5472 KB Output is correct
14 Correct 61 ms 7440 KB Output is correct
15 Correct 54 ms 7460 KB Output is correct
16 Correct 50 ms 7528 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 70 ms 7720 KB Output is correct
23 Correct 70 ms 7628 KB Output is correct
24 Correct 55 ms 4956 KB Output is correct
25 Correct 71 ms 7680 KB Output is correct
26 Correct 58 ms 7528 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 320 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 76 ms 8104 KB Output is correct
35 Correct 67 ms 8136 KB Output is correct
36 Correct 72 ms 8040 KB Output is correct
37 Correct 73 ms 8188 KB Output is correct
38 Correct 60 ms 8116 KB Output is correct
39 Correct 34 ms 4592 KB Output is correct
40 Correct 3 ms 468 KB Output is correct
41 Correct 3 ms 544 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 4 ms 468 KB Output is correct
44 Correct 94 ms 8656 KB Output is correct
45 Correct 103 ms 8600 KB Output is correct
46 Correct 86 ms 8544 KB Output is correct
47 Correct 92 ms 8536 KB Output is correct
48 Correct 67 ms 8512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 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 316 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 320 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 324 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 3 ms 596 KB Output is correct
27 Correct 3 ms 596 KB Output is correct
28 Correct 3 ms 584 KB Output is correct
29 Correct 3 ms 596 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 3 ms 456 KB Output is correct
33 Correct 3 ms 588 KB Output is correct
34 Correct 4 ms 588 KB Output is correct
35 Correct 1 ms 328 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 2 ms 468 KB Output is correct
38 Correct 5 ms 468 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 316 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 320 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 212 KB Output is correct
47 Correct 1 ms 272 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 55 ms 7504 KB Output is correct
51 Correct 43 ms 4484 KB Output is correct
52 Correct 48 ms 5472 KB Output is correct
53 Correct 61 ms 7440 KB Output is correct
54 Correct 54 ms 7460 KB Output is correct
55 Correct 50 ms 7528 KB Output is correct
56 Correct 1 ms 320 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 70 ms 7720 KB Output is correct
62 Correct 70 ms 7628 KB Output is correct
63 Correct 55 ms 4956 KB Output is correct
64 Correct 71 ms 7680 KB Output is correct
65 Correct 58 ms 7528 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 320 KB Output is correct
70 Correct 4 ms 468 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 76 ms 8104 KB Output is correct
74 Correct 67 ms 8136 KB Output is correct
75 Correct 72 ms 8040 KB Output is correct
76 Correct 73 ms 8188 KB Output is correct
77 Correct 60 ms 8116 KB Output is correct
78 Correct 34 ms 4592 KB Output is correct
79 Correct 3 ms 468 KB Output is correct
80 Correct 3 ms 544 KB Output is correct
81 Correct 2 ms 468 KB Output is correct
82 Correct 4 ms 468 KB Output is correct
83 Correct 94 ms 8656 KB Output is correct
84 Correct 103 ms 8600 KB Output is correct
85 Correct 86 ms 8544 KB Output is correct
86 Correct 92 ms 8536 KB Output is correct
87 Correct 67 ms 8512 KB Output is correct
88 Correct 115 ms 10156 KB Output is correct
89 Correct 119 ms 10160 KB Output is correct
90 Correct 104 ms 10172 KB Output is correct
91 Correct 112 ms 10076 KB Output is correct
92 Correct 102 ms 8884 KB Output is correct
93 Correct 113 ms 9320 KB Output is correct
94 Correct 95 ms 8936 KB Output is correct
95 Correct 80 ms 10068 KB Output is correct
96 Correct 106 ms 10084 KB Output is correct
97 Correct 71 ms 10264 KB Output is correct
98 Correct 65 ms 8992 KB Output is correct
99 Correct 164 ms 9028 KB Output is correct