#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<long long, pair<long long,long long> > > sd;
for(long long i=1; i<=n; i++){
long long x,y,z;
cin>>x>>y>>z;
p[i]={x, {y,z}};
sd.insert(p[i]);
}
sort(p+1, p+n+1, greater<pair<long long, pair<long long,long long> > >() );
long long pas=-1;
multiset<pair<long long, pair<long long,long long> > >::iterator it=sd.end();
it--;
multiset<pair<long long,long long> > vx,vy;
while(true){
pair<long long, pair<long long,long long> > px;
px=*it;
vx.insert({px.s.f, px.s.s});
vy.insert({px.s.s, px.s.f});
if(it==sd.begin()){
break;
}
it--;
}
for(long long i=1; i<=n; i++){
if(vx.find({p[i].s.f, p[i].s.s})==vx.end()){
vx.erase(vx.find({p[i].s.f, p[i].s.s}));
}
if(vy.find({p[i].s.s, p[i].s.f})==vy.end()){
vy.erase(vy.find({p[i].s.s, p[i].s.f}));
}
while( (*vx.rbegin()).f==(*vy.rbegin()).s && (*vx.rbegin()).s==(*vy.rbegin()).f){
vx.erase(--vx.end());
vy.erase(--vy.end());
if(!vx.size() || !vy.size()){
break;
}
}
// cout<<"y";
if(!vx.size() || !vy.size()){
break;
}
// cout<<"z";
if((*vx.rbegin()).f<=p[i].s.f || (*vy.rbegin()).f<=p[i].s.s ){
continue;
}
pas=max(pas, p[i].f+(*vx.rbegin()).f+(*vy.rbegin()).f);
}
cout<<pas;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |