제출 #1124129

#제출 시각아이디문제언어결과실행 시간메모리
1124129epicci23카니발 티켓 (IOI20_tickets)C++17
60 / 100
606 ms54332 KiB
#include "tickets.h" #include "bits/stdc++.h" using namespace std; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> ans(n,vector<int>(m,-1)); long long tot = 0; for(int i=0;i<n;i++) for(int j=0;j<k;j++) tot -= x[i][j]; priority_queue<array<long long,2>> pq; vector<int> p(n,1); for(int i=0;i<n;i++) pq.push({x[i][k-p[i]]+x[i][m-p[i]],i}); for(int i=0;i<k*n/2;i++){ auto u = pq.top(); pq.pop(); tot += u[0]; int ind = u[1]; p[ind]++; pq.push({x[ind][k-p[ind]]+x[ind][m-p[ind]],ind}); } vector<int> lf(n); for(int i=0;i<n;i++) lf[i]=p[i]-1; array<int,2> tag[n]; for(int i=0;i<n;i++) tag[i]={0,0}; for(int i=0;i<k;i++){ vector<array<int,2>> v; for(int j=0;j<n;j++) v.push_back({lf[j],j}); sort(v.begin(),v.end()); reverse(v.begin(),v.end()); for(int j=0;j<n;j++){ int ind = v[j][1]; if(j<n/2){ lf[ind]--; tag[ind][1]++; ans[ind][m-tag[ind][1]]=i; } else{ ans[ind][tag[ind][0]]=i; tag[ind][0]++; } } } allocate_tickets(ans); return tot; }
#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...