Submission #1230910

#TimeUsernameProblemLanguageResultExecution timeMemory
1230910PlayVoltzCarnival Tickets (IOI20_tickets)C++20
16 / 100
3095 ms97616 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define mp make_pair #define pb push_back #define fi first #define se second long long find_maximum(int k, vector<vector<int> > x){ int n=x.size(), m=x[0].size(); long long res=0; vector<int> l(n, k-1), r(n, m-1); vector<vector<int> > ans(n, vector<int>(m, -1)), t(n, vector<int>(m, 0)), got(n, vector<int>(m, 0)); vector<vector<pii> > vect(n, vector<pii>(m)); priority_queue<pii> pq; for (int i=0; i<n; ++i){ for (int j=0; j<m; ++j)vect[i][j]=mp(x[i][j], j); sort(vect[i].begin(), vect[i].end()); for (int j=0; j<k; ++j)res-=vect[i][j].fi, t[i][vect[i][j].se]=-1; pq.push(mp(vect[i][l[i]].fi+vect[i][r[i]].fi, i)); } for (int i=0; i<n*k/2; ++i){ pii c=pq.top(); pq.pop(); res+=c.fi; t[c.se][vect[c.se][l[c.se]].se]=0; t[c.se][vect[c.se][r[c.se]].se]=1; --l[c.se]; --r[c.se]; if (l[c.se]>=0)pq.push(mp(vect[c.se][l[c.se]].fi+vect[c.se][r[c.se]].fi, c.se)); } vector<pair<int, pii> > low, high; for (int i=0; i<n; ++i)for (int j=0; j<m; ++j){ if (t[i][j]==-1)low.pb(mp(x[i][j], mp(i, j))); else if (t[i][j])high.pb(mp(x[i][j], mp(i, j))); } for (int i=0; i<low.size(); ++i)ans[low[i].se.fi][low[i].se.se]=i%k, got[i%k][low[i].se.fi]=1; for (int i=0, c=0; i<high.size(); ++i){ while (got[c%k][high[i].se.fi])++c; ans[high[i].se.fi][high[i].se.se]=c%k; got[c%k][high[i].se.fi]=1; } allocate_tickets(ans); return res; }
#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...