#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()){
bool f=false;
if((*vx.rbegin()).s>=p[i].f){
vx.erase(--vx.end());
f=true;
}
if((*vy.rbegin()).s>=p[i].f){
vy.erase(--vx.end());
f=true;
}
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);
f=true;
}
if(!f){
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |