제출 #1050735

#제출 시각아이디문제언어결과실행 시간메모리
1050735TahirAliyev카니발 티켓 (IOI20_tickets)C++17
100 / 100
479 ms75348 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define ll long long ll find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> res; res.resize(n); for(int i = 0; i < n; i++) res[i].resize(m, -1); ll ans = 0; priority_queue<pii> q; vector<int> pre(n, k), suf(n, 0); for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ ans -= x[i][j]; } q.push({x[i][k - 1] + x[i][m - 1], i}); } for(int z = 0; z < k * n / 2; z++){ pii a = q.top(); q.pop(); ans += a.first; pre[a.second]--; suf[a.second]++; if(suf[a.second] == k) continue; q.push({x[a.second][m - suf[a.second] - 1] + x[a.second][pre[a.second] - 1], a.second}); } for(int r = 0; r < k; r++){ vector<pii> v; for(int i = 0; i < n; i++){ v.push_back({suf[i], i}); } sort(v.rbegin(), v.rend()); for(int i = 0; i < n / 2; i++){ res[v[i].second][m - v[i].first] = r; suf[v[i].second]--; } for(int i = n / 2; i < n; i++){ res[v[i].second][pre[v[i].second] - 1] = r; pre[v[i].second]--; } } allocate_tickets(res); 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...