Submission #302446

#TimeUsernameProblemLanguageResultExecution timeMemory
302446cgiosyCarnival Tickets (IOI20_tickets)C++17
27 / 100
758 ms42500 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; using ll=long long; #define R(i,n,...) for(int i=__VA_ARGS__+0; i<(n); ++i) struct pii { int x, i, j; bool operator<(const pii b) const { return x<b.x; } }; ll find_maximum(int K, vector<vector<int>> A) { const int N=A.size(); const int M=A[0].size(); const int X=N*K/2; ll sum=0; vector<pii> B(N*K); R(i, N) { R(j, K) { sum+=A[i][M-K+j]; B[i*K+j]={A[i][M-K+j]+A[i][j], i, j}; } fill(begin(A[i]), end(A[i]), -1); } sort(begin(B), end(B)); vector<int> C(N), D(K), E(K); int st=0; R(i, X) sum-=B[i].x, C[B[i].i]++; R(i, N) { int k=0, ed=st+C[i], cnt=0; R(j, K-C[i]) { while((st<=k && k<ed) || E[k]==N/2) k++; ++E[A[i][M-j-1]=k++]; } R(j, C[i]) cnt+=++D[A[i][j]=st+j]==N/2; st+=cnt; } allocate_tickets(A); 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...