Submission #301022

#TimeUsernameProblemLanguageResultExecution timeMemory
301022IgorICarnival Tickets (IOI20_tickets)C++17
27 / 100
751 ms51460 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<int> fr(n), to(n, m - 1); vector<vector<int> > ans(n, vector<int>(m, -1)); long long res = 0; for (int e = 0; e < k; e++) { long long cur = 0; vector<pair<long long, int> > upd; for (int i = 0; i < n; i++) { cur -= x[i][fr[i]]; upd.push_back({x[i][fr[i]] + x[i][to[i]], i}); } sort(upd.begin(), upd.end()); reverse(upd.begin(), upd.end()); for (int i = 0; i < n / 2; i++) { cur += upd[i].first; int id = upd[i].second; ans[id][to[id]] = e; to[id]--; } for (int i = n / 2; i < n; i++) { int id = upd[i].second; ans[id][fr[id]] = e; fr[id]++; } res += cur; } allocate_tickets(ans); 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...