제출 #405943

#제출 시각아이디문제언어결과실행 시간메모리
405943ngrace카니발 티켓 (IOI20_tickets)C++14
11 / 100
3 ms844 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define p pair #define pq priority_queue #define v vector #define card pair<int,pair<int,int>> long long find_maximum(int k, v<v<int>> x) { long long out=0; int n=x.size();//num colours int m=x[0].size();//num of each colour pq<card> mi; v<v<card>> small(n); v<v<card>> l(n); v<v<card>> s(n); v<v<int>> answer(n,v<int>(m,-1)); for(int i=0;i<n;i++){//initilize long list pq<card> ma; for(int j=0;j<m;j++){ ma.push({x[i][j],{i,j}}); small[i].push_back({-x[i][j],{i,j}}); } for(int j=0;j<k;j++){ card cur=ma.top(); ma.pop(); mi.push({-cur.first,cur.second}); l[i].push_back(cur); } sort(small[i].begin(),small[i].end()); } int count=0; while(count<k*n/2){//transfer to short list take smallest in large and remove and replace card cur = mi.top(); mi.pop(); int colInd=cur.second.first; if(l[colInd].size()>0){ l[colInd].pop_back(); pair<int,pair<int,int>> newS=small[colInd][small[colInd].size()-1]; s[colInd].push_back({-newS.first, newS.second}); small[colInd].pop_back(); count++; } } for(int i=0;i<k;i++){//allocate pq<pair<int,int>> numL; for(int j=0;j<n;j++){ numL.push({l[j].size(),j}); } int sm=0; int la=0; for(int j=0;j<n;j++){ bool takeL=false; if(j<n/2){ takeL=true; } int colInd=numL.top().second; numL.pop(); if(takeL){ card cur=l[colInd][l[colInd].size()-1]; answer[colInd][cur.second.second]=i; out+=cur.first; l[colInd].pop_back(); la++; } else{ card cur=s[colInd][s[colInd].size()-1]; answer[colInd][cur.second.second]=i; out-=cur.first; s[colInd].pop_back(); sm++; } } } allocate_tickets(answer); return out; }
#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...