Submission #319793

#TimeUsernameProblemLanguageResultExecution timeMemory
319793akobiCarnival Tickets (IOI20_tickets)C++14
100 / 100
1058 ms57704 KiB
#include "tickets.h" #include<bits/stdc++.h> #define ll long long #define F first #define S second #define pb push_back #define mp make_pair using namespace std; ll n,m,anss,c,cc; vector< vector<int> > ans; vector<int> temp; vector<ll> fix; set< pair<ll,ll> >s; pair<ll,ll> t; ll find_maximum(int k, vector< vector<int> > x) { n=x.size(); m=x[0].size(); for (int i=0; i<m; i++) temp.pb(-1); for (int i=0; i<n; i++) ans.pb(temp); for (int i=0; i<n; i++) fix.pb(0); for (int i=0; i<n; i++) { for (int j=m-k; j<m; j++) anss+=x[i][j]; s.insert( mp( x[i][0]+x[i][m-k] , i) ); } for (int c=0; c<k*n/2; c++) { t=*s.begin(); s.erase(*s.begin()); anss-=t.F; fix[t.S]++; if (fix[t.S]<k) s.insert( mp( x[t.S][fix[t.S]] + x[t.S][m-k+fix[t.S]] , t.S ) ); } for (int i=0; i<n; i++) { for (int j=0; j<fix[i]; j++) { ans[i][j]=c; c++; c%=k; } cc=c; for (int j=m-k+fix[i]; j<m; j++) { ans[i][j]=cc; cc++; cc%=k; } } allocate_tickets(ans); return anss; }
#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...