Submission #832336

#TimeUsernameProblemLanguageResultExecution timeMemory
832336JohannCarnival Tickets (IOI20_tickets)C++14
27 / 100
660 ms157128 KiB
#include "tickets.h" #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pii> vpii; #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() long long find_maximum(int K, std::vector<std::vector<int>> x) { int N = x.size(); int M = x[0].size(); ll value = 0; vvi ans(N, vi(M, -1)); vector<set<pii>> stuff(N); for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) stuff[i].insert({x[i][j], j}); for (int k = 0; k < K; ++k) { vpii choose; for (int i = 0; i < N; ++i) choose.push_back({stuff[i].begin()->first + stuff[i].rbegin()->first, i}); sort(all(choose)); for (int j = sz(choose) - 1; j >= sz(choose) / 2; --j) { int i = choose[j].second; value += stuff[i].rbegin()->first; ans[i][stuff[i].rbegin()->second] = k; stuff[i].erase(--stuff[i].end()); } for (int j = sz(choose) / 2 - 1; j >= 0; --j) { int i = choose[j].second; value -= stuff[i].begin()->first; ans[i][stuff[i].begin()->second] = k; stuff[i].erase(stuff[i].begin()); } } allocate_tickets(ans); return value; }
#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...