Submission #544523

#TimeUsernameProblemLanguageResultExecution timeMemory
544523blueTeam Contest (JOI22_team)C++17
100 / 100
891 ms44432 KiB
#include <iostream> #include <vector> #include <algorithm> #include <set> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int, int>; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; multiset<int> V[3]; set<pii> people[3]; int X[N][3]; for(int i = 0; i < N; i++) { for(int j = 0; j < 3; j++) { cin >> X[i][j]; V[j].insert(X[i][j]); people[j].insert({X[i][j], i}); } } int elim = 0; while(elim < N) { int fail = -1; for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { if(i == j) continue; int p = people[i].rbegin()->second; if(X[p][j] == *V[j].rbegin()) fail = p; } } if(fail == -1) { int res = 0; for(int k = 0; k < 3; k++) res += *V[k].rbegin(); cout << res << '\n'; return 0; } else { for(int k = 0; k < 3; k++) { V[k].erase(V[k].find(X[fail][k])); people[k].erase({X[fail][k], fail}); } elim++; } } 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...