제출 #401204

#제출 시각아이디문제언어결과실행 시간메모리
401204srvlt카니발 티켓 (IOI20_tickets)C++14
100 / 100
1303 ms92772 KiB
#include "tickets.h" #include <bits/stdc++.h> #define pb push_back #define all(x) begin(x),end(x) #define SZ(x) (int)(x).size() #define mem(x,y) memset(&x,y,sizeof(x)) #define ll long long using namespace std; const int n0=1503; vector<array<int,2>> pos[n0]; int l[n0],r[n0],used[n0]; ll find_maximum(int k, vector<vector<int>> x) { int n=SZ(x),m=SZ(x[0]); vector<vector<int>> answer(n,vector<int>(m,-1)); vector<array<int,3>> vec; ll s=0; for(int i=0; i<n; i++) { for(int j=0; j<k; j++) { s+=x[i][j+m-k]; vec.pb({-x[i][j]-x[i][j+m-k],-j,i}); } } sort(all(vec));reverse(all(vec)); set<array<int,2>> rows; for(int i=0; i<k*n/2; i++) { s+=vec[i][0]; l[vec[i][2]]++; } for(int i=0; i<n; i++) { l[i]--; rows.insert({l[i],i}); } for(int i=k-1; i>=0; i--) { assert(SZ(rows)>=n/2); auto it=prev(end(rows)); vector<int> todel; for(int j=0; j<n/2; j++) { int x=(*it)[1],y=(*it)[0]; answer[x][y]=i; pos[i].pb({x,y}); todel.pb(x); it--; } for(int x:todel) { rows.erase({l[x],x}); l[x]--; if(l[x]>=0) rows.insert({l[x],x}); } } for(int i=0; i<n; i++) r[i]=m-1; for(int i=0; i<k; i++) { mem(used,0); for(auto &j:pos[i]) { used[j[0]]=1; } for(int j=0; j<n; j++) { if(!used[j]) { answer[j][r[j]]=i; r[j]--; } } } allocate_tickets(answer); return s; }
#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...