#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
using namespace std;
int main(){
long long n;
cin>>n;
pair<long long, pair<long long,long long> > p[n+1];
multiset<pair<pair<long long,long long>, int> > vx,vy;
for(long long i=1; i<=n; i++){
long long x,y,z;
cin>>x>>y>>z;
p[i]={x, {y,z}};
vx.insert({{y, z}, x});
vy.insert({{z, y}, x});
}
sort(p+1, p+n+1, greater<pair<long long, pair<long long,long long> > >() );
long long pas=-1;
for(long long i=1; i<=n; i++){
while(vx.size() && vy.size()){
if((*vx.rbegin()).s>=p[i].f){
vx.erase(--vx.end());
}
else if((*vy.rbegin()).s>=p[i].f){
vy.erase(--vy.end());
}
else if((*vx.rbegin()).f.f==(*vy.rbegin()).f.s && (*vx.rbegin()).f.s==(*vy.rbegin()).f.f){
auto it1=vx.end();
it1--;
auto it2=vy.end();
it2--;
vx.erase(it1);
vy.erase(it2);
}else{
break;
}
}
if(!vx.size() || !vy.size()){
break;
}
if((*vx.rbegin()).f.f<=p[i].s.f || (*vy.rbegin()).f.f<=p[i].s.s ){
continue;
}
pas=max(pas, p[i].f+(*vx.rbegin()).f.f+(*vy.rbegin()).f.f);
}
cout<<pas;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 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 |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
300 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 |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 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 |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
300 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 |
212 KB |
Output is correct |
26 |
Correct |
8 ms |
980 KB |
Output is correct |
27 |
Correct |
11 ms |
980 KB |
Output is correct |
28 |
Correct |
8 ms |
932 KB |
Output is correct |
29 |
Correct |
8 ms |
932 KB |
Output is correct |
30 |
Correct |
5 ms |
724 KB |
Output is correct |
31 |
Correct |
6 ms |
820 KB |
Output is correct |
32 |
Correct |
8 ms |
852 KB |
Output is correct |
33 |
Correct |
10 ms |
924 KB |
Output is correct |
34 |
Correct |
7 ms |
980 KB |
Output is correct |
35 |
Correct |
1 ms |
436 KB |
Output is correct |
36 |
Correct |
2 ms |
428 KB |
Output is correct |
37 |
Correct |
8 ms |
852 KB |
Output is correct |
38 |
Correct |
7 ms |
828 KB |
Output is correct |
39 |
Correct |
3 ms |
564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
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 |
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 |
275 ms |
22576 KB |
Output is correct |
12 |
Correct |
157 ms |
15144 KB |
Output is correct |
13 |
Correct |
139 ms |
19248 KB |
Output is correct |
14 |
Correct |
206 ms |
23452 KB |
Output is correct |
15 |
Correct |
214 ms |
23464 KB |
Output is correct |
16 |
Correct |
143 ms |
23364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
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 |
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 |
275 ms |
22576 KB |
Output is correct |
12 |
Correct |
157 ms |
15144 KB |
Output is correct |
13 |
Correct |
139 ms |
19248 KB |
Output is correct |
14 |
Correct |
206 ms |
23452 KB |
Output is correct |
15 |
Correct |
214 ms |
23464 KB |
Output is correct |
16 |
Correct |
143 ms |
23364 KB |
Output is correct |
17 |
Correct |
1 ms |
212 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 |
296 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
312 ms |
23708 KB |
Output is correct |
23 |
Correct |
250 ms |
22940 KB |
Output is correct |
24 |
Correct |
171 ms |
17196 KB |
Output is correct |
25 |
Correct |
251 ms |
23644 KB |
Output is correct |
26 |
Correct |
169 ms |
23576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
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 |
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 |
275 ms |
22576 KB |
Output is correct |
12 |
Correct |
157 ms |
15144 KB |
Output is correct |
13 |
Correct |
139 ms |
19248 KB |
Output is correct |
14 |
Correct |
206 ms |
23452 KB |
Output is correct |
15 |
Correct |
214 ms |
23464 KB |
Output is correct |
16 |
Correct |
143 ms |
23364 KB |
Output is correct |
17 |
Correct |
1 ms |
212 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 |
296 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
312 ms |
23708 KB |
Output is correct |
23 |
Correct |
250 ms |
22940 KB |
Output is correct |
24 |
Correct |
171 ms |
17196 KB |
Output is correct |
25 |
Correct |
251 ms |
23644 KB |
Output is correct |
26 |
Correct |
169 ms |
23576 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 |
5 ms |
828 KB |
Output is correct |
32 |
Correct |
1 ms |
432 KB |
Output is correct |
33 |
Correct |
2 ms |
436 KB |
Output is correct |
34 |
Correct |
301 ms |
22976 KB |
Output is correct |
35 |
Correct |
300 ms |
21888 KB |
Output is correct |
36 |
Correct |
294 ms |
24060 KB |
Output is correct |
37 |
Correct |
337 ms |
24036 KB |
Output is correct |
38 |
Correct |
266 ms |
23544 KB |
Output is correct |
39 |
Correct |
100 ms |
14612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
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 |
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 |
275 ms |
22576 KB |
Output is correct |
12 |
Correct |
157 ms |
15144 KB |
Output is correct |
13 |
Correct |
139 ms |
19248 KB |
Output is correct |
14 |
Correct |
206 ms |
23452 KB |
Output is correct |
15 |
Correct |
214 ms |
23464 KB |
Output is correct |
16 |
Correct |
143 ms |
23364 KB |
Output is correct |
17 |
Correct |
1 ms |
212 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 |
296 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
312 ms |
23708 KB |
Output is correct |
23 |
Correct |
250 ms |
22940 KB |
Output is correct |
24 |
Correct |
171 ms |
17196 KB |
Output is correct |
25 |
Correct |
251 ms |
23644 KB |
Output is correct |
26 |
Correct |
169 ms |
23576 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 |
5 ms |
828 KB |
Output is correct |
32 |
Correct |
1 ms |
432 KB |
Output is correct |
33 |
Correct |
2 ms |
436 KB |
Output is correct |
34 |
Correct |
301 ms |
22976 KB |
Output is correct |
35 |
Correct |
300 ms |
21888 KB |
Output is correct |
36 |
Correct |
294 ms |
24060 KB |
Output is correct |
37 |
Correct |
337 ms |
24036 KB |
Output is correct |
38 |
Correct |
266 ms |
23544 KB |
Output is correct |
39 |
Correct |
100 ms |
14612 KB |
Output is correct |
40 |
Correct |
3 ms |
696 KB |
Output is correct |
41 |
Correct |
5 ms |
852 KB |
Output is correct |
42 |
Correct |
5 ms |
832 KB |
Output is correct |
43 |
Correct |
5 ms |
852 KB |
Output is correct |
44 |
Correct |
347 ms |
24584 KB |
Output is correct |
45 |
Correct |
361 ms |
24676 KB |
Output is correct |
46 |
Correct |
374 ms |
24640 KB |
Output is correct |
47 |
Correct |
380 ms |
24652 KB |
Output is correct |
48 |
Correct |
299 ms |
24600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 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 |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
300 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 |
212 KB |
Output is correct |
26 |
Correct |
8 ms |
980 KB |
Output is correct |
27 |
Correct |
11 ms |
980 KB |
Output is correct |
28 |
Correct |
8 ms |
932 KB |
Output is correct |
29 |
Correct |
8 ms |
932 KB |
Output is correct |
30 |
Correct |
5 ms |
724 KB |
Output is correct |
31 |
Correct |
6 ms |
820 KB |
Output is correct |
32 |
Correct |
8 ms |
852 KB |
Output is correct |
33 |
Correct |
10 ms |
924 KB |
Output is correct |
34 |
Correct |
7 ms |
980 KB |
Output is correct |
35 |
Correct |
1 ms |
436 KB |
Output is correct |
36 |
Correct |
2 ms |
428 KB |
Output is correct |
37 |
Correct |
8 ms |
852 KB |
Output is correct |
38 |
Correct |
7 ms |
828 KB |
Output is correct |
39 |
Correct |
3 ms |
564 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
1 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
47 |
Correct |
1 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 |
275 ms |
22576 KB |
Output is correct |
51 |
Correct |
157 ms |
15144 KB |
Output is correct |
52 |
Correct |
139 ms |
19248 KB |
Output is correct |
53 |
Correct |
206 ms |
23452 KB |
Output is correct |
54 |
Correct |
214 ms |
23464 KB |
Output is correct |
55 |
Correct |
143 ms |
23364 KB |
Output is correct |
56 |
Correct |
1 ms |
212 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 |
296 KB |
Output is correct |
60 |
Correct |
2 ms |
596 KB |
Output is correct |
61 |
Correct |
312 ms |
23708 KB |
Output is correct |
62 |
Correct |
250 ms |
22940 KB |
Output is correct |
63 |
Correct |
171 ms |
17196 KB |
Output is correct |
64 |
Correct |
251 ms |
23644 KB |
Output is correct |
65 |
Correct |
169 ms |
23576 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 |
5 ms |
828 KB |
Output is correct |
71 |
Correct |
1 ms |
432 KB |
Output is correct |
72 |
Correct |
2 ms |
436 KB |
Output is correct |
73 |
Correct |
301 ms |
22976 KB |
Output is correct |
74 |
Correct |
300 ms |
21888 KB |
Output is correct |
75 |
Correct |
294 ms |
24060 KB |
Output is correct |
76 |
Correct |
337 ms |
24036 KB |
Output is correct |
77 |
Correct |
266 ms |
23544 KB |
Output is correct |
78 |
Correct |
100 ms |
14612 KB |
Output is correct |
79 |
Correct |
3 ms |
696 KB |
Output is correct |
80 |
Correct |
5 ms |
852 KB |
Output is correct |
81 |
Correct |
5 ms |
832 KB |
Output is correct |
82 |
Correct |
5 ms |
852 KB |
Output is correct |
83 |
Correct |
347 ms |
24584 KB |
Output is correct |
84 |
Correct |
361 ms |
24676 KB |
Output is correct |
85 |
Correct |
374 ms |
24640 KB |
Output is correct |
86 |
Correct |
380 ms |
24652 KB |
Output is correct |
87 |
Correct |
299 ms |
24600 KB |
Output is correct |
88 |
Correct |
473 ms |
26384 KB |
Output is correct |
89 |
Correct |
471 ms |
26436 KB |
Output is correct |
90 |
Correct |
444 ms |
26428 KB |
Output is correct |
91 |
Correct |
496 ms |
26468 KB |
Output is correct |
92 |
Correct |
328 ms |
25020 KB |
Output is correct |
93 |
Correct |
430 ms |
25280 KB |
Output is correct |
94 |
Correct |
383 ms |
25168 KB |
Output is correct |
95 |
Correct |
403 ms |
26348 KB |
Output is correct |
96 |
Correct |
329 ms |
26492 KB |
Output is correct |
97 |
Correct |
287 ms |
26496 KB |
Output is correct |
98 |
Correct |
228 ms |
25128 KB |
Output is correct |
99 |
Correct |
217 ms |
25132 KB |
Output is correct |