Submission #544850

# Submission time Handle Problem Language Result Execution time Memory
544850 2022-04-02T21:05:11 Z Ronin13 Team Contest (JOI22_team) C++14
100 / 100
126 ms 6364 KB
#include<iostream>
#include <math.h>
#include <queue>
#define ll long long
#define f first
#define s second
#define pii pair<int, int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll

#pragma optimization("unroll-loops")
#pragma optimize("Ofast")
#pragma optimize("3")
#pragma target("avx2,avx,fma")

using namespace std;


int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n; cin >> n;
    int x[n + 1];
    int y[n + 1];
    int z[n + 1];

    for(int i = 1; i <= n; i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    int ans = -1;
    priority_queue <pii> px, py, pz;
    for(int i = 1; i <= n; i++){
        px.push({x[i], i});
        py.push({y[i], i});
        pz.push({z[i], i});
    }
    while(!px.empty()){
        int i = px.top().s;
        px.pop();
        while(!py.empty()){
            int j = py.top().s;
            if(x[j] >= x[i]){
                py.pop();
                continue;
            }
            if(y[i] >= y[j])break;
            bool indd = false;
            while(!pz.empty()){
                int k = pz.top().s;
                if(x[k] >= x[i] || y[k] >= y[j]){pz.pop();continue;}
                if(z[j] >= z[k]){
                    indd = true;
                    break;
                }
                if(z[i] >= z[k])break;
                cout << z[k] + x[i] + y[j];
                return 0;
            }
            if(indd)py.pop();
            else break;
        }
    }
    cout << -1;
    return 0;
}

Compilation message

team.cpp:13: warning: ignoring '#pragma optimization ' [-Wunknown-pragmas]
   13 | #pragma optimization("unroll-loops")
      | 
team.cpp:14: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
   14 | #pragma optimize("Ofast")
      | 
team.cpp:15: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
   15 | #pragma optimize("3")
      | 
team.cpp:16: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
   16 | #pragma target("avx2,avx,fma")
      | 
team.cpp: In function 'int main()':
team.cpp:31:9: warning: unused variable 'ans' [-Wunused-variable]
   31 |     int ans = -1;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 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 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 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 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 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 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 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 468 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 3 ms 488 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 468 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 2 ms 468 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 38 ms 6316 KB Output is correct
12 Correct 47 ms 3884 KB Output is correct
13 Correct 34 ms 4816 KB Output is correct
14 Correct 83 ms 6272 KB Output is correct
15 Correct 82 ms 6240 KB Output is correct
16 Correct 57 ms 6324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 38 ms 6316 KB Output is correct
12 Correct 47 ms 3884 KB Output is correct
13 Correct 34 ms 4816 KB Output is correct
14 Correct 83 ms 6272 KB Output is correct
15 Correct 82 ms 6240 KB Output is correct
16 Correct 57 ms 6324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 39 ms 6268 KB Output is correct
23 Correct 46 ms 6228 KB Output is correct
24 Correct 56 ms 4256 KB Output is correct
25 Correct 98 ms 6320 KB Output is correct
26 Correct 76 ms 6272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 38 ms 6316 KB Output is correct
12 Correct 47 ms 3884 KB Output is correct
13 Correct 34 ms 4816 KB Output is correct
14 Correct 83 ms 6272 KB Output is correct
15 Correct 82 ms 6240 KB Output is correct
16 Correct 57 ms 6324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 39 ms 6268 KB Output is correct
23 Correct 46 ms 6228 KB Output is correct
24 Correct 56 ms 4256 KB Output is correct
25 Correct 98 ms 6320 KB Output is correct
26 Correct 76 ms 6272 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 3 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 38 ms 6180 KB Output is correct
35 Correct 67 ms 6276 KB Output is correct
36 Correct 85 ms 6256 KB Output is correct
37 Correct 102 ms 6248 KB Output is correct
38 Correct 79 ms 6196 KB Output is correct
39 Correct 35 ms 3652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 38 ms 6316 KB Output is correct
12 Correct 47 ms 3884 KB Output is correct
13 Correct 34 ms 4816 KB Output is correct
14 Correct 83 ms 6272 KB Output is correct
15 Correct 82 ms 6240 KB Output is correct
16 Correct 57 ms 6324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 39 ms 6268 KB Output is correct
23 Correct 46 ms 6228 KB Output is correct
24 Correct 56 ms 4256 KB Output is correct
25 Correct 98 ms 6320 KB Output is correct
26 Correct 76 ms 6272 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 3 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 38 ms 6180 KB Output is correct
35 Correct 67 ms 6276 KB Output is correct
36 Correct 85 ms 6256 KB Output is correct
37 Correct 102 ms 6248 KB Output is correct
38 Correct 79 ms 6196 KB Output is correct
39 Correct 35 ms 3652 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 1 ms 468 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 2 ms 468 KB Output is correct
44 Correct 44 ms 6268 KB Output is correct
45 Correct 120 ms 6328 KB Output is correct
46 Correct 87 ms 6348 KB Output is correct
47 Correct 113 ms 6260 KB Output is correct
48 Correct 90 ms 6272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 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 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 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 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 468 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 3 ms 488 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 468 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 2 ms 468 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 38 ms 6316 KB Output is correct
51 Correct 47 ms 3884 KB Output is correct
52 Correct 34 ms 4816 KB Output is correct
53 Correct 83 ms 6272 KB Output is correct
54 Correct 82 ms 6240 KB Output is correct
55 Correct 57 ms 6324 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 0 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 39 ms 6268 KB Output is correct
62 Correct 46 ms 6228 KB Output is correct
63 Correct 56 ms 4256 KB Output is correct
64 Correct 98 ms 6320 KB Output is correct
65 Correct 76 ms 6272 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 0 ms 340 KB Output is correct
68 Correct 0 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 3 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 38 ms 6180 KB Output is correct
74 Correct 67 ms 6276 KB Output is correct
75 Correct 85 ms 6256 KB Output is correct
76 Correct 102 ms 6248 KB Output is correct
77 Correct 79 ms 6196 KB Output is correct
78 Correct 35 ms 3652 KB Output is correct
79 Correct 2 ms 340 KB Output is correct
80 Correct 1 ms 468 KB Output is correct
81 Correct 2 ms 468 KB Output is correct
82 Correct 2 ms 468 KB Output is correct
83 Correct 44 ms 6268 KB Output is correct
84 Correct 120 ms 6328 KB Output is correct
85 Correct 87 ms 6348 KB Output is correct
86 Correct 113 ms 6260 KB Output is correct
87 Correct 90 ms 6272 KB Output is correct
88 Correct 61 ms 6336 KB Output is correct
89 Correct 98 ms 6272 KB Output is correct
90 Correct 60 ms 6324 KB Output is correct
91 Correct 126 ms 6260 KB Output is correct
92 Correct 65 ms 6324 KB Output is correct
93 Correct 97 ms 6324 KB Output is correct
94 Correct 108 ms 6272 KB Output is correct
95 Correct 98 ms 6260 KB Output is correct
96 Correct 84 ms 6272 KB Output is correct
97 Correct 96 ms 6256 KB Output is correct
98 Correct 55 ms 6272 KB Output is correct
99 Correct 84 ms 6364 KB Output is correct