Submission #419514

#TimeUsernameProblemLanguageResultExecution timeMemory
419514vkgainzCarnival Tickets (IOI20_tickets)C++17
27 / 100
628 ms56172 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(); int64_t ans = 0; vector<vector<int>> assign(n, vector<int>(m, -1)); for(int r = 0; r < k; r++) { vector<ins> in; for(int i = 0; i < n; i++) { int mn = -1, mx = -1; for(int j = 0; j < m; j++) { if(x[i][j] == -1) continue; if(mn == -1 || mx == -1) mn = j, mx = j; if(x[i][j] < x[i][mn]) mn = j; if(x[i][j] > x[i][mx]) mx = j; } in.push_back({x[i][mn] + x[i][mx], mn, mx, i}); } sort(in.begin(), in.end(), cmp); for(int i = 0; i < n; i++) { if(i < n / 2) { ans -= x[in[i].idx][in[i].sidx]; x[in[i].idx][in[i].sidx] = -1; assign[in[i].idx][in[i].sidx] = r; } else { ans += x[in[i].idx][in[i].lidx]; x[in[i].idx][in[i].lidx] = -1; assign[in[i].idx][in[i].lidx] = r; } } } 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...