Submission #587972

#TimeUsernameProblemLanguageResultExecution timeMemory
587972SeDunionTeam Contest (JOI22_team)C++17
100 / 100
107 ms7944 KiB
#include<iostream> #include<algorithm> using namespace std; const int N = 1e6 + 123; using pii = pair<int,int>; pii x[N], y[N], z[N]; int ix[N], iy[N], iz[N]; int used[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 0 ; i < n ; ++ i) { cin >> ix[i] >> iy[i] >> iz[i]; x[i] = {ix[i], i}; y[i] = {iy[i], i}; z[i] = {iz[i], i}; } sort(x, x + n); sort(y, y + n); sort(z, z + n); int a = n - 1, b = n - 1, c = n - 1; while (a >= 0 && b >= 0 && c >= 0) { int i = x[a].second, j = y[b].second, k = z[c].second; if (iy[i] == iy[j] || iz[i] == iz[k] || used[i]) { used[i] = 1, --a; continue; } if (ix[i] == ix[j] || iz[j] == iz[k] || used[j]) { used[j] = 1, --b; continue; } if (iy[j] == iy[k] || ix[i] == ix[k] || used[k]) { used[k] = 1, --c; continue; } if (ix[i] > ix[j] && ix[i] > ix[k] && iy[j] > iy[i] && iy[j] > iy[k] && iz[k] > iz[i] && iz[k] > iz[j]) { cout << ix[i] + iy[j] + iz[k]; return 0; } } cout << -1; }
#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...