Submission #1015543

#TimeUsernameProblemLanguageResultExecution timeMemory
1015543UnforgettableplCarnival Tickets (IOI20_tickets)C++17
100 / 100
465 ms76116 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; void allocate_tickets( std::vector<std::vector<int>> _x); long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> anss(n,vector<int>(m,-1)); ll ans=0; vector<int> status(n,k-1); priority_queue<pair<ll,ll>> deltaq; for(int i=0;i<n;i++){ for(int j=0;j<k;j++)ans-=x[i][j]; deltaq.emplace(x[i][k-1]+x[i][m-1],i); } for(int i=0;i<(n/2)*k;i++){ auto [change,idx] = deltaq.top();deltaq.pop(); ans+=change; status[idx]--; if(status[idx]==-1)continue; deltaq.emplace(x[idx][status[idx]]+x[idx][m-k+status[idx]],idx); } int round = 0; for(int i=0;i<n;i++){ for(int j=0;j<=status[i];j++)anss[i][j]=(round++)%k; int t = round; for(int j=m-k+status[i]+1;j<m;j++)anss[i][j]=(t++)%k; } allocate_tickets(anss); 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...