Submission #419583

#TimeUsernameProblemLanguageResultExecution timeMemory
419583vkgainzCarnival Tickets (IOI20_tickets)C++17
100 / 100
910 ms67316 KiB
#include <bits/stdc++.h> using namespace std; 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 b = k - 1; b >= 0; b--) { c.push_back({x[i][b + m - k] + 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][m - 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; } } allocate_tickets(assign); return ans; }
#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...