Submission #308837

#TimeUsernameProblemLanguageResultExecution timeMemory
308837cgiosyCarnival Tickets (IOI20_tickets)C++17
100 / 100
1012 ms45496 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define R(i,n,...) for(int i=__VA_ARGS__+0; i<(n); ++i) struct pii { int x, i; bool operator<(const pii b) const { return x>b.x; } }; long long find_maximum(int K, vector<vector<int>> A) { const int N=A.size(), M=A[0].size(), X=N*K/2; vector<int> C(N); long long sum=0; priority_queue<pii> Q; R(i, N) Q.push({A[i][M-K]+A[i][0], i}); R(k, X) { int i=Q.top().i, &j=C[i]; Q.pop(); sum-=A[i][j]; if(++j<K) Q.push({A[i][j]+A[i][M-K+j], i}); } R(i, N) R(j, K, C[i]) sum+=A[i][M-K+j]; int l=0; R(i, N) { fill(begin(A[i]), end(A[i]), -1); R(j, C[i]) A[i][j]=l=l+1==K ? 0 : l+1; int r=l; R(j, K-C[i]) A[i][M-j-1]=r=r+1==K ? 0 : r+1; } 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...