제출 #435828

#제출 시각아이디문제언어결과실행 시간메모리
435828prvocislo카니발 티켓 (IOI20_tickets)C++17
49 / 100
3097 ms86552 KiB
#include "tickets.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); ll ans = 0; vector<int> mi(n, 0); // kolko minusov mame v tomto riadku priority_queue<pair<ll, int> > p1; // vymenime nejake velke cislo za male cislo for (int i = 0; i < n/2; i++) // zoberieme len maxima { for (int j = 0; j < k; j++) { p1.push({-x[i][j] - x[i][m - k + j], i}); ans += x[i][m - k + j]; } } priority_queue<pair<ll, int> > p2; for (int i = n/2; i < n; i++) // zoberieme len minima { mi[i] = k; for (int j = 0; j < k; j++) { p2.push({x[i][j] + x[i][m - k + j], i}); ans -= x[i][j]; } } while (p1.top().first + p2.top().first > 0) // vieme to urobit aj lepsie { ans += p1.top().first + p2.top().first; mi[p1.top().second]++; mi[p2.top().second]--; p1.pop(), p2.pop(); } vector<pair<int, int> > v(k); vector<vector<int> > s(n, vector<int>(m, -1)); for (int i = 0; i < k; i++) v[i] = {0,i}; for (int i = 0; i < n; i++) { int cnt = 0; sort(v.begin(), v.end()); for (int j = 0; j < mi[i]; j++) v[j].first++, s[i][j] = v[cnt++].second; for (int j = m - (k - mi[i]); j < m; j++) s[i][j] = v[cnt++].second; } 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...