#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
using namespace std;
int main(){
int n;
cin>>n;
pair<int, pair<int,int> > p[n+1];
set<pair<int, pair<int,int> > > sd;
for(int i=1; i<=n; i++){
int x,y,z;
cin>>x>>y>>z;
p[i]={x, {y,z}};
sd.insert(p[i]);
}
sort(p+1, p+n+1, greater<pair<int, pair<int,int> > >() );
int pas=-1;
for(int i=1; i<=n; i++){
set<pair<int, pair<int,int> > >::iterator it=sd.lower_bound({p[i].f, {0, 0}});
if(it==sd.begin()){
continue;
}
it--;
vector<pair<int,int> > vx,vy;
while(true){
pair<int, pair<int,int> > px;
px=*it;
vx.pb({px.s.f, px.s.s});
vy.pb({px.s.s, px.s.f});
if(it==sd.begin()){
break;
}
it--;
}
sort(vx.begin(), vx.end());
sort(vy.begin(), vy.end());
int i1=0,i2=0;
// cout<<vx.size()<<" u "<<vy.size() <<endl;
while(vx[vx.size()-1].f==vx[vx.size()-1].f && vx[vx.size()-1].s==vy[vy.size()-1].f){
// cout<<vx[vx.size()-1].f<<" assfgh "<<vx[vx.size()-1].f<<" s "<<vx[vx.size()-1].s<<" "<<vy[vy.size()-1].f<<endl ;
vx.pop_back();
vy.pop_back();
// cout<<vx[vx.size()-1].f<<endl;
// cout<<vy[vy.size()-1].f<<endl;
}
// cout<<vx.size()<<" asd "<<vy.size() <<endl;
if(!vx.size() || !vy.size()){
continue;
}
// cout<<"s"<<endl;
if(vx[vx.size()-1].f<=p[i].s.f || vy[vy.size()-1].f<=p[i].s.s ){
continue;
}
// cout<<"enter"<<endl;
// cout<<endl;
// cout<<p[i].f<<" "<<vx[vx.size()-1].f<<" "<<vy[vy.size()-1].f<<endl;
pas=max(pas, p[i].f+vx[vx.size()-1].f+vy[vy.size()-1].f);
}
cout<<pas;
}
Compilation message
team.cpp: In function 'int main()':
team.cpp:38:7: warning: unused variable 'i1' [-Wunused-variable]
38 | int i1=0,i2=0;
| ^~
team.cpp:38:12: warning: unused variable 'i2' [-Wunused-variable]
38 | int i1=0,i2=0;
| ^~
# |
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 |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 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 |
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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
300 KB |
Output is correct |
14 |
Correct |
5 ms |
336 KB |
Output is correct |
15 |
Correct |
4 ms |
304 KB |
Output is correct |
16 |
Correct |
5 ms |
304 KB |
Output is correct |
17 |
Correct |
5 ms |
340 KB |
Output is correct |
18 |
Correct |
5 ms |
212 KB |
Output is correct |
19 |
Correct |
5 ms |
212 KB |
Output is correct |
20 |
Correct |
3 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
3 ms |
212 KB |
Output is correct |
25 |
Correct |
3 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 |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 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 |
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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
300 KB |
Output is correct |
14 |
Correct |
5 ms |
336 KB |
Output is correct |
15 |
Correct |
4 ms |
304 KB |
Output is correct |
16 |
Correct |
5 ms |
304 KB |
Output is correct |
17 |
Correct |
5 ms |
340 KB |
Output is correct |
18 |
Correct |
5 ms |
212 KB |
Output is correct |
19 |
Correct |
5 ms |
212 KB |
Output is correct |
20 |
Correct |
3 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
3 ms |
212 KB |
Output is correct |
25 |
Correct |
3 ms |
340 KB |
Output is correct |
26 |
Correct |
1030 ms |
776 KB |
Output is correct |
27 |
Correct |
1049 ms |
756 KB |
Output is correct |
28 |
Correct |
1083 ms |
776 KB |
Output is correct |
29 |
Correct |
1074 ms |
760 KB |
Output is correct |
30 |
Correct |
465 ms |
596 KB |
Output is correct |
31 |
Correct |
1175 ms |
724 KB |
Output is correct |
32 |
Correct |
1000 ms |
704 KB |
Output is correct |
33 |
Correct |
131 ms |
628 KB |
Output is correct |
34 |
Correct |
329 ms |
724 KB |
Output is correct |
35 |
Correct |
23 ms |
340 KB |
Output is correct |
36 |
Correct |
22 ms |
340 KB |
Output is correct |
37 |
Correct |
452 ms |
724 KB |
Output is correct |
38 |
Correct |
443 ms |
720 KB |
Output is correct |
39 |
Correct |
182 ms |
468 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 |
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 |
1 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 |
484 ms |
2928 KB |
Output is correct |
12 |
Correct |
128 ms |
2024 KB |
Output is correct |
13 |
Correct |
92 ms |
2508 KB |
Output is correct |
14 |
Correct |
216 ms |
2924 KB |
Output is correct |
15 |
Correct |
98 ms |
2916 KB |
Output is correct |
16 |
Correct |
61 ms |
2920 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 |
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 |
1 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 |
484 ms |
2928 KB |
Output is correct |
12 |
Correct |
128 ms |
2024 KB |
Output is correct |
13 |
Correct |
92 ms |
2508 KB |
Output is correct |
14 |
Correct |
216 ms |
2924 KB |
Output is correct |
15 |
Correct |
98 ms |
2916 KB |
Output is correct |
16 |
Correct |
61 ms |
2920 KB |
Output is correct |
17 |
Correct |
0 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 |
3 ms |
212 KB |
Output is correct |
21 |
Correct |
179 ms |
476 KB |
Output is correct |
22 |
Execution timed out |
2064 ms |
4120 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
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 |
1 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 |
484 ms |
2928 KB |
Output is correct |
12 |
Correct |
128 ms |
2024 KB |
Output is correct |
13 |
Correct |
92 ms |
2508 KB |
Output is correct |
14 |
Correct |
216 ms |
2924 KB |
Output is correct |
15 |
Correct |
98 ms |
2916 KB |
Output is correct |
16 |
Correct |
61 ms |
2920 KB |
Output is correct |
17 |
Correct |
0 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 |
3 ms |
212 KB |
Output is correct |
21 |
Correct |
179 ms |
476 KB |
Output is correct |
22 |
Execution timed out |
2064 ms |
4120 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
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 |
1 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 |
484 ms |
2928 KB |
Output is correct |
12 |
Correct |
128 ms |
2024 KB |
Output is correct |
13 |
Correct |
92 ms |
2508 KB |
Output is correct |
14 |
Correct |
216 ms |
2924 KB |
Output is correct |
15 |
Correct |
98 ms |
2916 KB |
Output is correct |
16 |
Correct |
61 ms |
2920 KB |
Output is correct |
17 |
Correct |
0 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 |
3 ms |
212 KB |
Output is correct |
21 |
Correct |
179 ms |
476 KB |
Output is correct |
22 |
Execution timed out |
2064 ms |
4120 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
300 KB |
Output is correct |
5 |
Correct |
1 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 |
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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
300 KB |
Output is correct |
14 |
Correct |
5 ms |
336 KB |
Output is correct |
15 |
Correct |
4 ms |
304 KB |
Output is correct |
16 |
Correct |
5 ms |
304 KB |
Output is correct |
17 |
Correct |
5 ms |
340 KB |
Output is correct |
18 |
Correct |
5 ms |
212 KB |
Output is correct |
19 |
Correct |
5 ms |
212 KB |
Output is correct |
20 |
Correct |
3 ms |
212 KB |
Output is correct |
21 |
Correct |
2 ms |
212 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
3 ms |
212 KB |
Output is correct |
25 |
Correct |
3 ms |
340 KB |
Output is correct |
26 |
Correct |
1030 ms |
776 KB |
Output is correct |
27 |
Correct |
1049 ms |
756 KB |
Output is correct |
28 |
Correct |
1083 ms |
776 KB |
Output is correct |
29 |
Correct |
1074 ms |
760 KB |
Output is correct |
30 |
Correct |
465 ms |
596 KB |
Output is correct |
31 |
Correct |
1175 ms |
724 KB |
Output is correct |
32 |
Correct |
1000 ms |
704 KB |
Output is correct |
33 |
Correct |
131 ms |
628 KB |
Output is correct |
34 |
Correct |
329 ms |
724 KB |
Output is correct |
35 |
Correct |
23 ms |
340 KB |
Output is correct |
36 |
Correct |
22 ms |
340 KB |
Output is correct |
37 |
Correct |
452 ms |
724 KB |
Output is correct |
38 |
Correct |
443 ms |
720 KB |
Output is correct |
39 |
Correct |
182 ms |
468 KB |
Output is correct |
40 |
Correct |
0 ms |
212 KB |
Output is correct |
41 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
46 |
Correct |
1 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 |
484 ms |
2928 KB |
Output is correct |
51 |
Correct |
128 ms |
2024 KB |
Output is correct |
52 |
Correct |
92 ms |
2508 KB |
Output is correct |
53 |
Correct |
216 ms |
2924 KB |
Output is correct |
54 |
Correct |
98 ms |
2916 KB |
Output is correct |
55 |
Correct |
61 ms |
2920 KB |
Output is correct |
56 |
Correct |
0 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 |
3 ms |
212 KB |
Output is correct |
60 |
Correct |
179 ms |
476 KB |
Output is correct |
61 |
Execution timed out |
2064 ms |
4120 KB |
Time limit exceeded |
62 |
Halted |
0 ms |
0 KB |
- |