Submission #419561

#TimeUsernameProblemLanguageResultExecution timeMemory
419561vkgainzCarnival Tickets (IOI20_tickets)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; struct ins { int val, sidx, lidx, idx; }; bool cmp(ins &x, ins &y) { if(x.val == y.val) return x.idx < y.idx; return x.val < y.val; } void allocate_tickets(vector<vector<int>> s); int64_t find_maximum(int k, vector<vector<int>> x) { int n = (int) x.size(), m = (int) x[0].size(); vector<vector<int>> assign(n, vector<int>(m, -1)); int64_t ans = 0; vector<pair<int, int>> c; vector<int> take(n); for(int i = 0; i < n; i++) { for(int j = 0; j < k; j++) { ans -= x[i][j]; } for(int a = n - 1, b = k - 1; b >= 0; a--, b--) { c.push_back({x[i][a] + x[i][b], i}); } } sort(c.begin(), c.end()); for(int i = 0; i < n * k / 2; i++) { take[c.back().second]++; ans += c.back().first; c.pop_back(); } int l = 0, r = k - 1; for(int i = 0; i < n; i++) { for(int j = 0; j < take[i]; j++) { assign[i][n - 1 - j] = r; --r; if(r < 0) r += k; } for(int j = 0; j < k - take[i]; j++) { assign[i][j] = l; ++l; if(l >= k) l -= k; } } return ans; allocate_tickets(assign); }
#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...