Submission #419506

#TimeUsernameProblemLanguageResultExecution timeMemory
419506vkgainzCarnival Tickets (IOI20_tickets)C++17
0 / 100
1 ms296 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(); int64_t ans = 0; vector<vector<int>> assign(n, vector<int>(m)); for(int r = 0; r < k; r++) { vector<pair<int, pair<int, int>>> 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], {mx, mn}}); } sort(in.begin(), in.end()); for(int i = 0; i < n; i++) { int take; if(i < n / 2) take = in[i].second.second; else take = in[i].second.first; if(i < n / 2) ans -= x[i][take]; else ans += x[i][take]; assign[i][take] = 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...