제출 #305947

#제출 시각아이디문제언어결과실행 시간메모리
305947baluteshih카니발 티켓 (IOI20_tickets)C++14
100 / 100
957 ms63352 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define X first #define Y second #define ALL(v) v.begin(),v.end() #define SZ(a) ((int)a.size()) #define pb push_back const ll INF=1e18; ll find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); int tar=n*k/2; ll sum=0; vector<vector<int>> answer(n,vector<int>(m,-1)),que(n,vector<int>(k,0)); vector<int> cnt(n,0),num(n,0),nw(n,0),tp(n,0),pl(n,0); priority_queue<pii> pq; for(int i=0;i<n;++i) { for(int j=0;j<k;++j) sum-=x[i][j]; for(int j=1;j<=k;++j) que[i][j-1]=x[i][k-j]+x[i][m-j]; pq.push(pii(que[i][0],i)); } for(int i=0;i<tar;++i) { auto u=pq.top(); pq.pop(); ++cnt[u.Y],++pl[u.Y],sum+=u.X; if(pl[u.Y]<k) pq.push(pii(que[u.Y][pl[u.Y]],u.Y)); } for(int i=0;i<n;++i) nw[i]=k-cnt[i],num[i]=i,tp[i]=cnt[i]; for(int i=0;i<k;++i) { sort(ALL(num),[&](int a,int b){return cnt[a]>cnt[b];}); for(int j=0;j<n/2;++j) answer[num[j]][m-tp[num[j]]+(--cnt[num[j]])]=i; for(int j=n/2;j<n;++j) answer[num[j]][--nw[num[j]]]=i; } allocate_tickets(answer); return sum; }
#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...