Submission #998295

#TimeUsernameProblemLanguageResultExecution timeMemory
998295abczzTeam Contest (JOI22_team)C++17
0 / 100
1 ms4540 KiB
#include <iostream> #include <array> #include <algorithm> #define ll long long using namespace std; array <ll, 3> A[150000], B[150000], C[150000]; ll n; int main() { cin >> n; for (int i=0; i<n; ++i) { for (int j=0; j<3; ++j) { cin >> A[i][j]; B[i][j] = C[i][j] = A[i][j]; } } sort(A, A+n, [](auto a, auto b) { return a[0] > b[0]; }); sort(B, B+n, [](auto a, auto b) { return a[1] > b[1]; }); sort(C, C+n, [](auto a, auto b) { return a[2] > b[2]; }); int i = 0, j = 0, k = 0; while (i < n && j < n && k < n) { while (j < n && A[i][0] <= B[j][0]) ++j; while (k < n && A[i][0] <= C[k][0]) ++k; if (j >= n || k >= n) break; while (i < n && B[j][1] <= A[i][1]) ++i; while (k < n && B[j][1] <= C[k][1]) ++k; if (i >= n || k >= n) break; while (i < n && C[k][2] <= A[i][2]) ++i; while (j < n && C[k][2] <= B[j][2]) ++j; if (i >= n || j >= n) break; cout << A[i][0] + B[j][1] + C[k][2] << '\n'; 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...