Submission #545349

#TimeUsernameProblemLanguageResultExecution timeMemory
545349MeloricTeam Contest (JOI22_team)C++14
100 / 100
104 ms7436 KiB
#include <bits/stdc++.h> #define pb push_back #define int int64_t #define pii pair<int, int> #define X first #define Y second #define all(x) (x).begin(),(x).end() #define lb lower_bound #define ub upper_bound using namespace std; const int inf = 1e18; void solve(){ int n; cin >> n; vector<int> x(n), y(n), z(n); for(int i = 0; i< n; i++)cin >> x[i] >> y[i] >> z[i]; vector<int> sx(n), sy(n), sz(n); for(int i = 0; i< n; i++)sx[i] = sy[i] = sz[i] = i; sort(all(sx), [&](int i, int j){return x[i] < x[j];}); sort(all(sy), [&](int i, int j){return y[i] < y[j];}); sort(all(sz), [&](int i, int j){return z[i] < z[j];}); int a=n-1, b=n-1, c=n-1; while(a >= 0 && b >= 0 && c >= 0){ if(y[sx[a]] >= y[sy[b]] || z[sx[a]] >= z[sz[c]]){a--; continue;} if(x[sy[b]] >= x[sx[a]] || z[sy[b]] >= z[sz[c]]){b--; continue;} if(x[sz[c]] >= x[sx[a]] || y[sz[c]] >= y[sy[b]]){c--; continue;} break; } if(a < 0 || b < 0 || c < 0)cout << -1; else cout << x[sx[a]] + y[sy[b]] + z[sz[c]]; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; //cin >> t; while(t--)solve(); }
#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...