#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long long
// the most CHALISHKANCHIK
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
void solve(){
int n;
cin >> n;
vector<int> x(n),y(n),z(n);
vector<pair<int,int>> vx,vy,vz;
for(int i = 0;i < n;i++){
cin >> x[i] >> y[i] >> z[i];
vx.pb({x[i],i});
vy.pb({y[i],i});
vz.pb({z[i],i});
}
sort(all(vx));
sort(all(vy));
sort(all(vz));
int px = n - 1,py = n - 1,pz = n - 1;
while(px >= 0 && py >= 0 && pz >= 0){
auto [nx,p1] = vx[px];
auto [ny,p2] = vy[py];
auto [nz,p3] = vz[pz];
if(y[p1] >= ny || z[p1] >= nz){
px--;
} else if(x[p2] >= nx || z[p2] >= nz){
py--;
} else if(x[p3] >= nx || y[p3] >= ny){
pz--;
} else{
cout << nx + ny + nz << "\n";
return 0;
}
}
cout << "-1\n";
}
main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int test = 1;
//~ cin >> test;
while(test--){
solve();
}
}
Compilation message
team.cpp: In function 'void solve()':
team.cpp:41:11: error: return-statement with a value, in function returning 'void' [-fpermissive]
41 | return 0;
| ^
team.cpp: At global scope:
team.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
46 | main(){
| ^~~~