Submission #928075

#TimeUsernameProblemLanguageResultExecution timeMemory
928075EJIC_B_KEDAXCarnival Tickets (IOI20_tickets)C++17
25 / 100
473 ms76012 KiB
#include <bits/stdc++.h> #include "tickets.h" using ll = long long; using namespace std; ll find_maximum(int k, vector<vector<int>> t) { int n = t.size(), m = t[0].size(); vector<int> all; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { all.push_back(t[i][j]); } } sort(all.begin(), all.end()); int middle = all[all.size() / 2]; ll res = 0; vector<pair<ll, int>> a(n); vector<int> bg(n, 0), end(n, m - 1); vector<vector<int>> s(n, vector<int>(m, -1)); for (int i = 0; i < n; i++) { a[i].first = 0; a[i].second = i; for (int j = 0; j < m; j++) { t[i][j] -= middle; a[i].first += t[i][j]; } } for (int r = 0; r < k; r++) { vector<int> nw; sort(a.begin(), a.end()); for (int i = 0; i < n / 2; i++) { a[i].first -= t[a[i].second][bg[a[i].second]]; nw.push_back(t[a[i].second][bg[a[i].second]]); s[a[i].second][bg[a[i].second]++] = r; } for (int i = n / 2; i < n; i++) { a[i].first -= t[a[i].second][end[a[i].second]]; nw.push_back(t[a[i].second][end[a[i].second]]); s[a[i].second][end[a[i].second]--] = r; } for (int i : nw) { res += abs(i); } assert(0 >= nw[n / 2 - 1] && 0 <= nw[n / 2]); } allocate_tickets(s); return res; }
#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...