Submission #603915

#TimeUsernameProblemLanguageResultExecution timeMemory
603915CyberCowCarnival Tickets (IOI20_tickets)C++17
0 / 100
0 ms212 KiB
#include "tickets.h" #include <vector> #include <cmath> #include <algorithm> #include <set> using namespace std; using ll = long long; ll n, m; long long find_maximum(int k, vector<vector<int>> x) { n = x.size(); m = x[0].size(); vector<vector<int>>anss(n, vector<int>(m, -1)); vector<set<pair<ll, ll>>> v(n); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { v[i].insert({ x[i][j], j }); } } ll ans = 0; for (int i = 0; i < k; i++) { vector<ll> q; for (int j = 0; j < n/2; j++) { q.push_back(v[j].begin()->first); anss[j][v[j].begin()->second] = i; v[j].erase(v[j].begin()); } for (int j = n/2; j < n; j++) { q.push_back((--v[j].end())->first); anss[j][(--v[j].end())->second] = i; v[j].erase(--v[j].end()); } for (int j = 0; j < n; j++) { ans += abs(q[j] - q[n / 2]); } } allocate_tickets(anss); 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...