Submission #576730

#TimeUsernameProblemLanguageResultExecution timeMemory
576730SlavicGCarnival Tickets (IOI20_tickets)C++17
0 / 100
1 ms212 KiB
#include "bits/stdc++.h" #include "tickets.h" using namespace std; #define ll long long #define sz(a) (int)a.size() #define pb push_back #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define forn(i, n) for(int i=0;i < n; ++i) long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); std::vector<std::vector<int>> answer(n, vector<int>(m, -1)); deque<pair<int, int>> d[n]; for(int i = 0; i < n; ++i) { for(int j = 0; j < m; ++j) { d[i].pb({x[i][j], j}); } sort(all(d[i])); } ll ans = 0; for(int kk = 0; kk < m; ++kk) { priority_queue<pair<int, int>> q; forn(i, n) q.push({d[i].front().first + d[i].back().first, i}); vector<int> v; for(int j = 0; j < sz(q) / 2; ++j) { int i = q.top().second; q.pop(); answer[i][d[i].front().second] = kk; ans -= d[i].front().first; d[i].pop_front(); } for(int j = 0; j < sz(q) / 2; ++j) { int i = q.top().second; q.pop(); answer[i][d[i].back().second] = kk; ans += d[i].back().first; d[i].pop_back(); } } allocate_tickets(answer); 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...