제출 #318420

#제출 시각아이디문제언어결과실행 시간메모리
318420nickmet2004카니발 티켓 (IOI20_tickets)C++14
100 / 100
793 ms76260 KiB
#include<bits/stdc++.h> #include "tickets.h" using namespace std; int cnt[1505]; int n , m ,k; vector<vector<int>>a; long long find_maximum(int k , vector<vector<int>> a){ int n = a.size() , m = a[0].size(); /// nk/2 maximums - nk/2 minimums priority_queue<pair<int , int>> pq; long long ans = 0; for(int i = 0; i < n; ++i){ for(int j = 0; j < k; ++j) ans += a[i][m - k + j]; pq.emplace(-a[i][0] - a[i][m - k] , i); } /// --k for(int i = 0; i < n * k / 2; ++i){ auto x = pq.top(); pq.pop(); int q = x.second; ans += x.first; if(++cnt[q] < k) pq.emplace(-a[q][cnt[q]] - a[q][m - k + cnt[q]] , q); } vector<vector<int>> r(n , vector<int>(m , -1)); /// nk/2 divide into n/2 groups int mnL = 0 , mxR = 0; for(int i = 0; i < n; ++i){ for(int j = 0; j < cnt[i]; ++j) r[i][j] = mnL++ , mnL%= k; mxR = mnL; for(int j = m - k + cnt[i]; j < m; ++j) r[i][j] = mxR++ , mxR%= k; } allocate_tickets(r); 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...