Submission #1124134

#TimeUsernameProblemLanguageResultExecution timeMemory
1124134epicci23Carnival Tickets (IOI20_tickets)C++17
60 / 100
779 ms54456 KiB
#include "tickets.h" #include "bits/stdc++.h" using namespace std; long long find_maximum(int k, vector<vector<int>> x) { long long n = x.size(),m = x[0].size(),tot = 0; vector<vector<int>> ans(n,vector<int>(m,-1)); priority_queue<array<long long,2>> pq; vector<long long> 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++){ array<long long,2> u = pq.top(); pq.pop(); long long ind = u[1]; p[ind]++; pq.push({x[ind][k-p[ind]]+x[ind][m-p[ind]],ind}); } vector<long long> lf(n); for(int i=0;i<n;i++) lf[i]=p[i]-1; array<long long,2> tag[n]; for(int i=0;i<n;i++) tag[i]={0,0}; for(int i=0;i<k;i++){ vector<array<long long,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()); vector<long long> vals; for(int j=0;j<n;j++){ long long ind = v[j][1]; if(j<n/2){ lf[ind]--; tag[ind][1]++; ans[ind][m-tag[ind][1]]=i; vals.push_back(x[ind][m-tag[ind][1]]); } else{ vals.push_back(x[ind][tag[ind][0]]); ans[ind][tag[ind][0]]=i; tag[ind][0]++; } } sort(vals.begin(),vals.end()); for(int j=0;j<n;j++){ if(j<n/2) tot -= vals[j]; else tot += vals[j]; } } 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...