제출 #497268

#제출 시각아이디문제언어결과실행 시간메모리
497268Hanksburger카니발 티켓 (IOI20_tickets)C++17
100 / 100
695 ms76184 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; priority_queue<pair<long long, long long> > pq; pair<long long, long long> CNT[1505]; vector<vector<int> > ans; long long cnt[1505]; bool chosen[1505]; vector<int> tmp; long long find_maximum(int K, vector<vector<int> > X) { long long N=X.size(), M=X[0].size(), sum=0; for (long long i=0; i<N; i++) for (long long j=0; j<K; j++) sum-=X[i][j]; for (long long i=0; i<N; i++) pq.push({X[i][K-1]+X[i][M-1], i}); for (long long i=0; i<N*K/2; i++) { long long p=pq.top().first, q=pq.top().second; pq.pop(); sum+=p; cnt[q]++; if (cnt[q]<K) pq.push({X[q][K-cnt[q]-1]+X[q][M-cnt[q]-1], q}); } for (long long i=0; i<N; i++) { tmp.clear(); for (long long j=0; j<M; j++) tmp.push_back(-1); ans.push_back(tmp); } for (long long i=0; i<N; i++) CNT[i]={cnt[i], i}; for (long long i=0; i<K; i++) { for (long long j=0; j<N; j++) chosen[j]=0; sort(CNT, CNT+N, greater<pair<long long, long long> >()); for (long long j=0; j<N/2; j++) { long long q=CNT[j].second; chosen[q]=1; ans[q][M-cnt[q]]=i; cnt[q]--; CNT[j].first--; } for (long long j=0; j<N; j++) if (!chosen[j]) ans[j][K-i-cnt[j]-1]=i; } allocate_tickets(ans); return sum; }
#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...