Submission #301214

#TimeUsernameProblemLanguageResultExecution timeMemory
301214IgorICarnival Tickets (IOI20_tickets)C++17
27 / 100
757 ms51504 KiB
#include <bits/stdc++.h> #include "tickets.h" using namespace std; long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(), m = x[0].size(); vector<vector<int> > ans(n, vector<int>(m, -1)); vector<pair<long long, pair<int, int> > > moo; for (int e = 0; e < k; e++) { for (int i = 0; i < n; i++) { ans[i][e] = e; moo.push_back({x[i][e] + x[i][e + m - k], {i, e}}); } } sort(moo.begin(), moo.end()); reverse(moo.begin(), moo.end()); for (int i = 0; i < n / 2 * k; i++) { int a = moo[i].second.first; int b = moo[i].second.second; int z = ans[a][b]; ans[a][b] = -1; ans[a][b + m - k] = z; } allocate_tickets(ans); long long res = 0; vector<vector<int> > day(k); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (ans[i][j] != -1) { day[ans[i][j]].push_back(x[i][j]); } } } for (int i = 0; i < k; i++) { sort(day[i].begin(), day[i].end()); for (int j = 0; j < n / 2; j++) { res += day[i][j + n / 2] - day[i][j]; } } return res; }
#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...