| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 965931 | PM1 | Team Contest (JOI22_team) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mxn=2e5;
int n,a[mxn][3];
vector<int>z,zz,zzz;
bool cmp1(int x,int y){
return a[x][0]<a[y][0];
}
bool cmp2(int x,int y){
return a[x][1]<a[y][1];
}
bool cmp3(int x,int y){
return a[x][2]<a[y][2];
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i][0]>>a[i][1]>>a[i][2];
z.push_back(i);
}
zzz=zz=z;
sort(z.begin(),z.end(),cmp1);
sort(zz.begin(),zz.end(),cmp2);
sort(zzz.begin(),zzz.end(),cmp3);
int p1=n-1,p2=n-1,p3=n-1;
while(p1>-1 && p2>-1 && p3>-1){
if(a[z[p1]][0]<= a[zz[p2]][0]){
p2--;
continue;
}
if(a[z[p1]][0]<= a[zzz[p3]][0]){
p3--;
continue;
}
if(a[zz[p2]][1]<= a[z[p1]][1]){
p1--;
continue;
}
if(a[zz[p2]][1]<= a[zzz[p3]][1]){
p3--;
continue;
}
if(a[zzz[p3]][2]<= a[z[p1]][2]){
p1--;
continue;
}
if(a[zzz[p3]][2]<= a[zz[p2]][2]){
p2--;
continue;
}
/cout<<z[p1]<<" "<<zz[p2]<<" "<<zzz[p3]<<'\n';
cout<<a[z[p1]][0]+a[zz[p2]][1]+a[zzz[p3]][2];
return 0;
}
cout<<-1;
return 0;
}
