Submission #580572

#TimeUsernameProblemLanguageResultExecution timeMemory
580572CyberSleeperTeam Contest (JOI22_team)C++17
100 / 100
93 ms14836 KiB
#include <bits/stdc++.h> #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define debug(x) cout << "Line " << __LINE__ << ", " << #x << " is " << x << endl #define all(x) x.begin(), x.end() #define fi first #define se second #define mp make_pair #define pb push_back #define ll long long #define ull unsigned long long #define pll pair<ll, ll> #define pii pair<ll, ll> #define ld long double #define nl '\n' #define tb '\t' #define sp ' ' #define sqr(x) (x)*(x) #define arr3 array<ll, 3> using namespace std; const ll MX=150002, MOD=1000000007, BLOCK=160, INF=1e9+7, LG=62; const ll INFF=1000000000000000004; const ld ERR=1e-6, pi=3.14159265358979323846; ll N, X[MX], Y[MX], Z[MX]; pll A[MX], B[MX], C[MX]; int main(){ fastio; cin >> N; for(ll i=0; i<N; i++){ cin >> X[i] >> Y[i] >> Z[i]; A[i]={X[i], i}; B[i]={Y[i], i}; C[i]={Z[i], i}; } sort(A, A+N); sort(B, B+N); sort(C, C+N); ll px=N-1, py=N-1, pz=N-1; while(px>=0 && py>=0 && pz>=0){ ll x=A[px].se, y=B[py].se, z=C[pz].se; if(X[x]<=X[y]){py--; continue;} if(X[x]<=X[z]){pz--; continue;} if(Y[y]<=Y[x]){px--; continue;} if(Y[y]<=Y[z]){pz--; continue;} if(Z[z]<=Z[x]){px--; continue;} if(Z[z]<=Z[y]){py--; continue;} cout << X[x]+Y[y]+Z[z] << nl; return 0; } cout << "-1\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...