Submission #308833

#TimeUsernameProblemLanguageResultExecution timeMemory
308833cgiosyCarnival Tickets (IOI20_tickets)C++17
0 / 100
1 ms384 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(i, X) { int&j=C[Q.top().i]; Q.pop(); if(++j<K) Q.push({A[i][M-K+j]+A[i][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...