제출 #1043843

#제출 시각아이디문제언어결과실행 시간메모리
1043843aaaaaarroz카니발 티켓 (IOI20_tickets)C++17
100 / 100
508 ms104704 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define V vector #define VI V<int> V<VI> genalloc(V<VI>ones,V<VI>negs,int n,int m,int k){ V<VI>ans(n,VI(m,-1)); for(int i=0;i<k;i++){ int cnto=0,cntn=0; vector<int>netrl; for(int j=0;j<n;j++){ if(negs[j].empty()) ans[j][ones[j].back()]=i, ones[j].pop_back(),cnto++; else if(ones[j].empty()) ans[j][negs[j].back()]=i, negs[j].pop_back(),cntn++; else netrl.push_back(j); } for(auto j:netrl)if(cnto<n/2) ans[j][ones[j].back()]=i, ones[j].pop_back(),cnto++; else ans[j][negs[j].back()]=i, negs[j].pop_back(),cntn++; } return ans; } long long find_maximum(int k, V<VI> x) { int n = x.size(); int m = x[0].size(); priority_queue<pair<int,int>>pq; long long ans=0; V<VI> ones(n),negs(n); for(int i=0;i<n;i++)for(int j=0;j<k;j++) negs[i].push_back(j),ans-=x[i][j], pq.push({x[i][j]+x[i][m-k+j],i}); for(int q=0;q<n*k/2;q++){ auto[x,y]=pq.top(); ones[y].push_back(m-k+negs[y].back()); negs[y].pop_back();pq.pop();ans+=x; } allocate_tickets(genalloc(ones,negs,n,m,k)); 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...