제출 #930789

#제출 시각아이디문제언어결과실행 시간메모리
930789JooDdae카니발 티켓 (IOI20_tickets)C++17
25 / 100
890 ms85756 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; int N = n*m; vector<array<int, 2>> v; for(int i=0;i<n;i++) for(int j=0;j<m;j++) { v.push_back({x[i][j], i}); } sort(v.begin(), v.end()); ll ans = 0; vector<int> c(n, 0), L(n, 0); for(int i=0;i<N/2;i++) c[v[i][1]]++, ans += v[i+N/2][0] - v[i][0]; vector<int> R = c; priority_queue<array<int, 2>> pq; for(int i=0;i<n;i++) pq.push({c[i], i}); vector<vector<int>> re(n, vector<int>(m, -1)); for(int i=0;i<m;i++) { set<int> s; for(int j=0;j<n/2;j++) s.insert(pq.top()[1]), pq.pop(); for(int j=0;j<n;j++) { if(s.count(j)) re[j][L[j]++] = i; else re[j][R[j]++] = i; } for(auto x : s) pq.push({--c[x], x}); } allocate_tickets(re); 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...