Submission #436072

#TimeUsernameProblemLanguageResultExecution timeMemory
436072prvocisloCarnival Tickets (IOI20_tickets)C++17
100 / 100
1034 ms73092 KiB
#include "tickets.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; const int maxn = 2005; vector<int> cntm(maxn, 0); bool cmp(const int &i, const int &j) { return cntm[i] < cntm[j]; } long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); ll ans = 0; vector<int> l(n, -1), r(n, m); // kolko minusov mame v tomto riadku vector<pair<int, int> > p1; // vymenime nejake velke cislo za male cislo for (int i = 0; i < n; i++) // zoberieme len maxima { l[i] = -1, r[i] = m - k; for (int j = 0; j < k; j++) p1.push_back({x[i][j]+x[i][r[i]+j], i}), ans += x[i][r[i]+j]; } sort(p1.begin(), p1.end()); for (int i = 0; i < (n * k)/2; i++) l[p1[i].second]++, r[p1[i].second]++, ans -= p1[i].first; vector<int> v(k); vector<vector<int> > s(n, vector<int>(m, -1)); for (int i = 0; i < k; i++) v[i] = i; for (int i = 0; i < n; i++) { int cnt = 0; sort(v.begin(), v.end(), cmp); for (int j = 0; j <= l[i]; j++) cntm[v[j]]++, s[i][j] = v[cnt++]; for (int j = r[i]; j < m; j++) s[i][j] = v[cnt++]; } allocate_tickets(s); 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...