Submission #406012

#TimeUsernameProblemLanguageResultExecution timeMemory
406012tiberiuCarnival Tickets (IOI20_tickets)C++14
27 / 100
967 ms163440 KiB
#include "tickets.h" #include <vector> #include <algorithm> #include <iostream> #include <set> using namespace std; typedef pair<int, int> pii; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> ans = vector<vector<int>>(n, vector<int>(m, -1)); set<pii> t[n]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) t[i].insert({x[i][j], j}); long long win = 0; for (int r = 0; r < k; r++) { vector<pii> c; for (int j = 0; j < n; j++) { c.push_back({t[j].begin()->first + t[j].rbegin()->first, j}); // cout << c.back().first << ' '; } // cout << endl; sort(c.begin(), c.end()); for (int i = 0; i < n / 2; i++) { int col = c[i].second; int ix = t[col].begin()->second; win -= x[col][ix]; ans[col][ix] = r; t[col].erase({x[col][ix], ix}); } for (int i = n / 2; i < n; i++) { int col = c[i].second; int ix = t[col].rbegin()->second; win += x[col][ix]; ans[col][ix] = r; t[col].erase({x[col][ix], ix}); } } allocate_tickets(ans); return win; }
#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...