#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_multiset tree<type1, null_type, less_equal<type1>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
using namespace __gnu_pbds;
const int mod = 998244353;
const double PI = acos(-1.0);
const double epsilon = 1e-6;
const int N = 1.5e5+5;
int n;
vector<pair<int,int> > a(N),b(N),c(N);
void solve(){
cin >> n;
vector<int> x(n),y(n),z(n);
for(int 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(rall(a)); sort(rall(b)); sort(rall(c));
int posx = 0,posy = 0,posz = 0;
while(posx < n && posy < n && posz < n){
auto [xv,pos1] = a[posx];
auto [yv,pos2] = b[posy];
auto [zv,pos3] = c[posz];
if(y[pos1] >= yv || z[pos1] >= zv) posx++;
else if(x[pos2] >= xv || z[pos2] >= zv) posy++;
else if(x[pos3] >= xv || y[pos3] >= yv) posz++;
else{
cout << xv + yv + zv << '\n';
return;
}
}
cout << "-1\n";
}
main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
solve();
}
}
Compilation message
team.cpp:52:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
52 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
7516 KB |
Output is correct |
2 |
Correct |
9 ms |
7512 KB |
Output is correct |
3 |
Correct |
9 ms |
7524 KB |
Output is correct |
4 |
Correct |
9 ms |
7260 KB |
Output is correct |
5 |
Correct |
9 ms |
7260 KB |
Output is correct |
6 |
Correct |
9 ms |
7256 KB |
Output is correct |
7 |
Correct |
9 ms |
7256 KB |
Output is correct |
8 |
Correct |
9 ms |
7512 KB |
Output is correct |
9 |
Correct |
9 ms |
7516 KB |
Output is correct |
10 |
Correct |
9 ms |
7332 KB |
Output is correct |
11 |
Correct |
9 ms |
7260 KB |
Output is correct |
12 |
Correct |
9 ms |
7340 KB |
Output is correct |
13 |
Correct |
11 ms |
7668 KB |
Output is correct |
14 |
Correct |
9 ms |
7516 KB |
Output is correct |
15 |
Correct |
11 ms |
7516 KB |
Output is correct |
16 |
Correct |
10 ms |
7444 KB |
Output is correct |
17 |
Correct |
11 ms |
7272 KB |
Output is correct |
18 |
Correct |
12 ms |
7516 KB |
Output is correct |
19 |
Correct |
12 ms |
7516 KB |
Output is correct |
20 |
Correct |
12 ms |
7448 KB |
Output is correct |
21 |
Correct |
11 ms |
7512 KB |
Output is correct |
22 |
Correct |
9 ms |
7516 KB |
Output is correct |
23 |
Correct |
10 ms |
7524 KB |
Output is correct |
24 |
Correct |
11 ms |
7516 KB |
Output is correct |
25 |
Correct |
10 ms |
7516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
7516 KB |
Output is correct |
2 |
Correct |
9 ms |
7512 KB |
Output is correct |
3 |
Correct |
9 ms |
7524 KB |
Output is correct |
4 |
Correct |
9 ms |
7260 KB |
Output is correct |
5 |
Correct |
9 ms |
7260 KB |
Output is correct |
6 |
Correct |
9 ms |
7256 KB |
Output is correct |
7 |
Correct |
9 ms |
7256 KB |
Output is correct |
8 |
Correct |
9 ms |
7512 KB |
Output is correct |
9 |
Correct |
9 ms |
7516 KB |
Output is correct |
10 |
Correct |
9 ms |
7332 KB |
Output is correct |
11 |
Correct |
9 ms |
7260 KB |
Output is correct |
12 |
Correct |
9 ms |
7340 KB |
Output is correct |
13 |
Correct |
11 ms |
7668 KB |
Output is correct |
14 |
Correct |
9 ms |
7516 KB |
Output is correct |
15 |
Correct |
11 ms |
7516 KB |
Output is correct |
16 |
Correct |
10 ms |
7444 KB |
Output is correct |
17 |
Correct |
11 ms |
7272 KB |
Output is correct |
18 |
Correct |
12 ms |
7516 KB |
Output is correct |
19 |
Correct |
12 ms |
7516 KB |
Output is correct |
20 |
Correct |
12 ms |
7448 KB |
Output is correct |
21 |
Correct |
11 ms |
7512 KB |
Output is correct |
22 |
Correct |
9 ms |
7516 KB |
Output is correct |
23 |
Correct |
10 ms |
7524 KB |
Output is correct |
24 |
Correct |
11 ms |
7516 KB |
Output is correct |
25 |
Correct |
10 ms |
7516 KB |
Output is correct |
26 |
Correct |
10 ms |
7512 KB |
Output is correct |
27 |
Correct |
13 ms |
7516 KB |
Output is correct |
28 |
Correct |
14 ms |
8024 KB |
Output is correct |
29 |
Correct |
13 ms |
7516 KB |
Output is correct |
30 |
Correct |
12 ms |
7516 KB |
Output is correct |
31 |
Correct |
13 ms |
7516 KB |
Output is correct |
32 |
Correct |
13 ms |
7516 KB |
Output is correct |
33 |
Correct |
13 ms |
7516 KB |
Output is correct |
34 |
Correct |
11 ms |
7716 KB |
Output is correct |
35 |
Correct |
12 ms |
7516 KB |
Output is correct |
36 |
Correct |
11 ms |
7540 KB |
Output is correct |
37 |
Correct |
14 ms |
7772 KB |
Output is correct |
38 |
Correct |
11 ms |
7516 KB |
Output is correct |
39 |
Correct |
12 ms |
7580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
7512 KB |
Output is correct |
2 |
Correct |
9 ms |
7512 KB |
Output is correct |
3 |
Correct |
9 ms |
7260 KB |
Output is correct |
4 |
Correct |
10 ms |
7384 KB |
Output is correct |
5 |
Correct |
9 ms |
7512 KB |
Output is correct |
6 |
Correct |
9 ms |
7260 KB |
Output is correct |
7 |
Correct |
9 ms |
7256 KB |
Output is correct |
8 |
Correct |
11 ms |
7260 KB |
Output is correct |
9 |
Correct |
9 ms |
7516 KB |
Output is correct |
10 |
Correct |
9 ms |
7516 KB |
Output is correct |
11 |
Correct |
63 ms |
11528 KB |
Output is correct |
12 |
Correct |
42 ms |
10332 KB |
Output is correct |
13 |
Correct |
42 ms |
11048 KB |
Output is correct |
14 |
Correct |
58 ms |
11608 KB |
Output is correct |
15 |
Correct |
50 ms |
11612 KB |
Output is correct |
16 |
Correct |
66 ms |
11404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
7512 KB |
Output is correct |
2 |
Correct |
9 ms |
7512 KB |
Output is correct |
3 |
Correct |
9 ms |
7260 KB |
Output is correct |
4 |
Correct |
10 ms |
7384 KB |
Output is correct |
5 |
Correct |
9 ms |
7512 KB |
Output is correct |
6 |
Correct |
9 ms |
7260 KB |
Output is correct |
7 |
Correct |
9 ms |
7256 KB |
Output is correct |
8 |
Correct |
11 ms |
7260 KB |
Output is correct |
9 |
Correct |
9 ms |
7516 KB |
Output is correct |
10 |
Correct |
9 ms |
7516 KB |
Output is correct |
11 |
Correct |
63 ms |
11528 KB |
Output is correct |
12 |
Correct |
42 ms |
10332 KB |
Output is correct |
13 |
Correct |
42 ms |
11048 KB |
Output is correct |
14 |
Correct |
58 ms |
11608 KB |
Output is correct |
15 |
Correct |
50 ms |
11612 KB |
Output is correct |
16 |
Correct |
66 ms |
11404 KB |
Output is correct |
17 |
Correct |
9 ms |
7260 KB |
Output is correct |
18 |
Correct |
9 ms |
7460 KB |
Output is correct |
19 |
Correct |
9 ms |
7260 KB |
Output is correct |
20 |
Correct |
11 ms |
7516 KB |
Output is correct |
21 |
Correct |
15 ms |
7580 KB |
Output is correct |
22 |
Correct |
63 ms |
12108 KB |
Output is correct |
23 |
Correct |
64 ms |
11604 KB |
Output is correct |
24 |
Correct |
49 ms |
10584 KB |
Output is correct |
25 |
Correct |
65 ms |
11896 KB |
Output is correct |
26 |
Correct |
52 ms |
11716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
7512 KB |
Output is correct |
2 |
Correct |
9 ms |
7512 KB |
Output is correct |
3 |
Correct |
9 ms |
7260 KB |
Output is correct |
4 |
Correct |
10 ms |
7384 KB |
Output is correct |
5 |
Correct |
9 ms |
7512 KB |
Output is correct |
6 |
Correct |
9 ms |
7260 KB |
Output is correct |
7 |
Correct |
9 ms |
7256 KB |
Output is correct |
8 |
Correct |
11 ms |
7260 KB |
Output is correct |
9 |
Correct |
9 ms |
7516 KB |
Output is correct |
10 |
Correct |
9 ms |
7516 KB |
Output is correct |
11 |
Correct |
63 ms |
11528 KB |
Output is correct |
12 |
Correct |
42 ms |
10332 KB |
Output is correct |
13 |
Correct |
42 ms |
11048 KB |
Output is correct |
14 |
Correct |
58 ms |
11608 KB |
Output is correct |
15 |
Correct |
50 ms |
11612 KB |
Output is correct |
16 |
Correct |
66 ms |
11404 KB |
Output is correct |
17 |
Correct |
9 ms |
7260 KB |
Output is correct |
18 |
Correct |
9 ms |
7460 KB |
Output is correct |
19 |
Correct |
9 ms |
7260 KB |
Output is correct |
20 |
Correct |
11 ms |
7516 KB |
Output is correct |
21 |
Correct |
15 ms |
7580 KB |
Output is correct |
22 |
Correct |
63 ms |
12108 KB |
Output is correct |
23 |
Correct |
64 ms |
11604 KB |
Output is correct |
24 |
Correct |
49 ms |
10584 KB |
Output is correct |
25 |
Correct |
65 ms |
11896 KB |
Output is correct |
26 |
Correct |
52 ms |
11716 KB |
Output is correct |
27 |
Correct |
12 ms |
7512 KB |
Output is correct |
28 |
Correct |
13 ms |
7512 KB |
Output is correct |
29 |
Correct |
12 ms |
7512 KB |
Output is correct |
30 |
Correct |
10 ms |
7516 KB |
Output is correct |
31 |
Correct |
13 ms |
7516 KB |
Output is correct |
32 |
Correct |
11 ms |
7516 KB |
Output is correct |
33 |
Correct |
10 ms |
7544 KB |
Output is correct |
34 |
Correct |
63 ms |
12124 KB |
Output is correct |
35 |
Correct |
61 ms |
11868 KB |
Output is correct |
36 |
Correct |
67 ms |
12112 KB |
Output is correct |
37 |
Correct |
71 ms |
12268 KB |
Output is correct |
38 |
Correct |
55 ms |
12112 KB |
Output is correct |
39 |
Correct |
43 ms |
10320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
7512 KB |
Output is correct |
2 |
Correct |
9 ms |
7512 KB |
Output is correct |
3 |
Correct |
9 ms |
7260 KB |
Output is correct |
4 |
Correct |
10 ms |
7384 KB |
Output is correct |
5 |
Correct |
9 ms |
7512 KB |
Output is correct |
6 |
Correct |
9 ms |
7260 KB |
Output is correct |
7 |
Correct |
9 ms |
7256 KB |
Output is correct |
8 |
Correct |
11 ms |
7260 KB |
Output is correct |
9 |
Correct |
9 ms |
7516 KB |
Output is correct |
10 |
Correct |
9 ms |
7516 KB |
Output is correct |
11 |
Correct |
63 ms |
11528 KB |
Output is correct |
12 |
Correct |
42 ms |
10332 KB |
Output is correct |
13 |
Correct |
42 ms |
11048 KB |
Output is correct |
14 |
Correct |
58 ms |
11608 KB |
Output is correct |
15 |
Correct |
50 ms |
11612 KB |
Output is correct |
16 |
Correct |
66 ms |
11404 KB |
Output is correct |
17 |
Correct |
9 ms |
7260 KB |
Output is correct |
18 |
Correct |
9 ms |
7460 KB |
Output is correct |
19 |
Correct |
9 ms |
7260 KB |
Output is correct |
20 |
Correct |
11 ms |
7516 KB |
Output is correct |
21 |
Correct |
15 ms |
7580 KB |
Output is correct |
22 |
Correct |
63 ms |
12108 KB |
Output is correct |
23 |
Correct |
64 ms |
11604 KB |
Output is correct |
24 |
Correct |
49 ms |
10584 KB |
Output is correct |
25 |
Correct |
65 ms |
11896 KB |
Output is correct |
26 |
Correct |
52 ms |
11716 KB |
Output is correct |
27 |
Correct |
12 ms |
7512 KB |
Output is correct |
28 |
Correct |
13 ms |
7512 KB |
Output is correct |
29 |
Correct |
12 ms |
7512 KB |
Output is correct |
30 |
Correct |
10 ms |
7516 KB |
Output is correct |
31 |
Correct |
13 ms |
7516 KB |
Output is correct |
32 |
Correct |
11 ms |
7516 KB |
Output is correct |
33 |
Correct |
10 ms |
7544 KB |
Output is correct |
34 |
Correct |
63 ms |
12124 KB |
Output is correct |
35 |
Correct |
61 ms |
11868 KB |
Output is correct |
36 |
Correct |
67 ms |
12112 KB |
Output is correct |
37 |
Correct |
71 ms |
12268 KB |
Output is correct |
38 |
Correct |
55 ms |
12112 KB |
Output is correct |
39 |
Correct |
43 ms |
10320 KB |
Output is correct |
40 |
Correct |
12 ms |
7516 KB |
Output is correct |
41 |
Correct |
13 ms |
7516 KB |
Output is correct |
42 |
Correct |
13 ms |
7512 KB |
Output is correct |
43 |
Correct |
12 ms |
7512 KB |
Output is correct |
44 |
Correct |
68 ms |
12548 KB |
Output is correct |
45 |
Correct |
71 ms |
12416 KB |
Output is correct |
46 |
Correct |
71 ms |
12544 KB |
Output is correct |
47 |
Correct |
72 ms |
12476 KB |
Output is correct |
48 |
Correct |
56 ms |
12124 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
7516 KB |
Output is correct |
2 |
Correct |
9 ms |
7512 KB |
Output is correct |
3 |
Correct |
9 ms |
7524 KB |
Output is correct |
4 |
Correct |
9 ms |
7260 KB |
Output is correct |
5 |
Correct |
9 ms |
7260 KB |
Output is correct |
6 |
Correct |
9 ms |
7256 KB |
Output is correct |
7 |
Correct |
9 ms |
7256 KB |
Output is correct |
8 |
Correct |
9 ms |
7512 KB |
Output is correct |
9 |
Correct |
9 ms |
7516 KB |
Output is correct |
10 |
Correct |
9 ms |
7332 KB |
Output is correct |
11 |
Correct |
9 ms |
7260 KB |
Output is correct |
12 |
Correct |
9 ms |
7340 KB |
Output is correct |
13 |
Correct |
11 ms |
7668 KB |
Output is correct |
14 |
Correct |
9 ms |
7516 KB |
Output is correct |
15 |
Correct |
11 ms |
7516 KB |
Output is correct |
16 |
Correct |
10 ms |
7444 KB |
Output is correct |
17 |
Correct |
11 ms |
7272 KB |
Output is correct |
18 |
Correct |
12 ms |
7516 KB |
Output is correct |
19 |
Correct |
12 ms |
7516 KB |
Output is correct |
20 |
Correct |
12 ms |
7448 KB |
Output is correct |
21 |
Correct |
11 ms |
7512 KB |
Output is correct |
22 |
Correct |
9 ms |
7516 KB |
Output is correct |
23 |
Correct |
10 ms |
7524 KB |
Output is correct |
24 |
Correct |
11 ms |
7516 KB |
Output is correct |
25 |
Correct |
10 ms |
7516 KB |
Output is correct |
26 |
Correct |
10 ms |
7512 KB |
Output is correct |
27 |
Correct |
13 ms |
7516 KB |
Output is correct |
28 |
Correct |
14 ms |
8024 KB |
Output is correct |
29 |
Correct |
13 ms |
7516 KB |
Output is correct |
30 |
Correct |
12 ms |
7516 KB |
Output is correct |
31 |
Correct |
13 ms |
7516 KB |
Output is correct |
32 |
Correct |
13 ms |
7516 KB |
Output is correct |
33 |
Correct |
13 ms |
7516 KB |
Output is correct |
34 |
Correct |
11 ms |
7716 KB |
Output is correct |
35 |
Correct |
12 ms |
7516 KB |
Output is correct |
36 |
Correct |
11 ms |
7540 KB |
Output is correct |
37 |
Correct |
14 ms |
7772 KB |
Output is correct |
38 |
Correct |
11 ms |
7516 KB |
Output is correct |
39 |
Correct |
12 ms |
7580 KB |
Output is correct |
40 |
Correct |
9 ms |
7512 KB |
Output is correct |
41 |
Correct |
9 ms |
7512 KB |
Output is correct |
42 |
Correct |
9 ms |
7260 KB |
Output is correct |
43 |
Correct |
10 ms |
7384 KB |
Output is correct |
44 |
Correct |
9 ms |
7512 KB |
Output is correct |
45 |
Correct |
9 ms |
7260 KB |
Output is correct |
46 |
Correct |
9 ms |
7256 KB |
Output is correct |
47 |
Correct |
11 ms |
7260 KB |
Output is correct |
48 |
Correct |
9 ms |
7516 KB |
Output is correct |
49 |
Correct |
9 ms |
7516 KB |
Output is correct |
50 |
Correct |
63 ms |
11528 KB |
Output is correct |
51 |
Correct |
42 ms |
10332 KB |
Output is correct |
52 |
Correct |
42 ms |
11048 KB |
Output is correct |
53 |
Correct |
58 ms |
11608 KB |
Output is correct |
54 |
Correct |
50 ms |
11612 KB |
Output is correct |
55 |
Correct |
66 ms |
11404 KB |
Output is correct |
56 |
Correct |
9 ms |
7260 KB |
Output is correct |
57 |
Correct |
9 ms |
7460 KB |
Output is correct |
58 |
Correct |
9 ms |
7260 KB |
Output is correct |
59 |
Correct |
11 ms |
7516 KB |
Output is correct |
60 |
Correct |
15 ms |
7580 KB |
Output is correct |
61 |
Correct |
63 ms |
12108 KB |
Output is correct |
62 |
Correct |
64 ms |
11604 KB |
Output is correct |
63 |
Correct |
49 ms |
10584 KB |
Output is correct |
64 |
Correct |
65 ms |
11896 KB |
Output is correct |
65 |
Correct |
52 ms |
11716 KB |
Output is correct |
66 |
Correct |
12 ms |
7512 KB |
Output is correct |
67 |
Correct |
13 ms |
7512 KB |
Output is correct |
68 |
Correct |
12 ms |
7512 KB |
Output is correct |
69 |
Correct |
10 ms |
7516 KB |
Output is correct |
70 |
Correct |
13 ms |
7516 KB |
Output is correct |
71 |
Correct |
11 ms |
7516 KB |
Output is correct |
72 |
Correct |
10 ms |
7544 KB |
Output is correct |
73 |
Correct |
63 ms |
12124 KB |
Output is correct |
74 |
Correct |
61 ms |
11868 KB |
Output is correct |
75 |
Correct |
67 ms |
12112 KB |
Output is correct |
76 |
Correct |
71 ms |
12268 KB |
Output is correct |
77 |
Correct |
55 ms |
12112 KB |
Output is correct |
78 |
Correct |
43 ms |
10320 KB |
Output is correct |
79 |
Correct |
12 ms |
7516 KB |
Output is correct |
80 |
Correct |
13 ms |
7516 KB |
Output is correct |
81 |
Correct |
13 ms |
7512 KB |
Output is correct |
82 |
Correct |
12 ms |
7512 KB |
Output is correct |
83 |
Correct |
68 ms |
12548 KB |
Output is correct |
84 |
Correct |
71 ms |
12416 KB |
Output is correct |
85 |
Correct |
71 ms |
12544 KB |
Output is correct |
86 |
Correct |
72 ms |
12476 KB |
Output is correct |
87 |
Correct |
56 ms |
12124 KB |
Output is correct |
88 |
Correct |
69 ms |
13136 KB |
Output is correct |
89 |
Correct |
77 ms |
13096 KB |
Output is correct |
90 |
Correct |
71 ms |
13168 KB |
Output is correct |
91 |
Correct |
78 ms |
13148 KB |
Output is correct |
92 |
Correct |
74 ms |
12624 KB |
Output is correct |
93 |
Correct |
71 ms |
12624 KB |
Output is correct |
94 |
Correct |
73 ms |
12880 KB |
Output is correct |
95 |
Correct |
65 ms |
13316 KB |
Output is correct |
96 |
Correct |
70 ms |
13316 KB |
Output is correct |
97 |
Correct |
77 ms |
13144 KB |
Output is correct |
98 |
Correct |
66 ms |
12692 KB |
Output is correct |
99 |
Correct |
39 ms |
12764 KB |
Output is correct |