Submission #342120

#TimeUsernameProblemLanguageResultExecution timeMemory
342120SeDunionCarnival Tickets (IOI20_tickets)C++17
100 / 100
1105 ms114608 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; using ll = long long; ll find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> answer(n, vector<int>(m, -1)); vector<int> all(n); vector<int> np(n), pp(n, m); vector<pair<int,int>> now; ll Sum = 0; vector<pair<ll,int>> q; for (int i = 0 ; i < n ; ++ i) { for (int j = 0 ; j < k ; ++ j) { Sum -= x[i][j]; q.push_back({x[i][j] + x[i][m - k + j], i}); } } sort(q.rbegin(), q.rend()); for (int rep = 0 ; rep < n * k / 2 ; ++ rep) { auto [val, i] = q[rep]; Sum += val; all[i] += 2; } for (int c = 0 ; c < k ; ++ c) { now.clear(); for (int i = 0 ; i < n ; ++ i) now.push_back({all[i], i}); sort(now.begin(), now.end()); for (int j = 0 ; j < n / 2 ; ++ j) { int i = now[j].second; answer[i][np[i]++] = c; all[i]++; } for (int j = n / 2 ; j < n ; ++ j) { int i = now[j].second; answer[i][--pp[i]] = c; all[i]--; } } allocate_tickets(answer); return Sum; }
#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...