Submission #303311

#TimeUsernameProblemLanguageResultExecution timeMemory
303311baluteshihCarnival Tickets (IOI20_tickets)C++14
25 / 100
1103 ms85312 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; #define X first #define Y second #define ALL(v) v.begin(),v.end() #define SZ(a) ((int)a.size()) #define pb push_back const ll INF=1e18; struct mode { int x,i,j; bool operator<(const mode &a)const{ return x<a.x; } }; ll find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); ll rt=0; vector<vector<int>> answer(n,vector<int>(m,-1)); vector<vector<int>> used(n,vector<int>(m,0)); vector<int> cnt(n,0),num(n,0),nw(n,0),tp(n,0); vector<mode> v; for(int i=0;i<n;++i) for(int j=0;j<m;++j) v.pb(mode{x[i][j],i,j}); sort(ALL(v)); for(int i=n*m/2;i<SZ(v);++i) ++cnt[v[i].i]; for(int i=0;i<n;++i) nw[i]=m-cnt[i],num[i]=i,tp[i]=cnt[i]; for(int i=0;i<m;++i) { sort(ALL(num),[&](int a,int b){return cnt[a]>cnt[b];}); for(int j=0;j<n/2;++j) rt+=x[num[j]][m-tp[num[j]]+(--cnt[num[j]])],answer[num[j]][m-tp[num[j]]+cnt[num[j]]]=i; for(int j=n/2;j<n;++j) rt-=x[num[j]][--nw[num[j]]],answer[num[j]][nw[num[j]]]=i; } allocate_tickets(answer); return rt; }
#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...