제출 #300875

#제출 시각아이디문제언어결과실행 시간메모리
300875ainta카니발 티켓 (IOI20_tickets)C++17
100 / 100
1279 ms71972 KiB
#include "tickets.h" #include <vector> #include <algorithm> #define pii pair<int,int> using namespace std; int n, m, K, cc, L[1600], R[1600]; int PL[1600], PR[1600]; pii CL[1600]; vector<pii>V; long long find_maximum(int k, std::vector<std::vector<int>> x) { vector<vector<int>>res = x; n = x.size(); m = x[0].size(); K = k; int i, j; for(i=0;i<n;i++)for(j=0;j<m;j++)res[i][j]=-1; for(i=0;i<n;i++){ for(j=0;j<K;j++){ int b = x[i][j]; int e = x[i][m-K+j]; V.push_back({e+b,i}); } } sort(V.begin(),V.end()); for(i=0;i<n*K/2;i++){ L[V[i].second]++; } for(i=0;i<n;i++){ R[i]=K-L[i]; PL[i]=0,PR[i]=m-1; } long long ss=0; for(i=0;i<K;i++){ for(j=0;j<n;j++){ CL[j]={L[j],j}; } sort(CL,CL+n); for(j=0;j<n;j++){ int t = CL[j].second; if(j<n/2){ R[t]--; ss+=x[t][PR[t]]; res[t][PR[t]--] = i; } else{ L[t]--; ss-=x[t][PL[t]]; res[t][PL[t]++] = i; } } } allocate_tickets(res); return ss; }
#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...