Submission #308828

#TimeUsernameProblemLanguageResultExecution timeMemory
308828cgiosyCarnival Tickets (IOI20_tickets)C++17
0 / 100
1 ms256 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(); long long sum=0; priority_queue<pii> Q; R(i, N/2) R(j, K) { sum+=A[i][M-K+j]; Q.push({A[i][M-K+j]+A[i][j], i}); } R(i, N, N/2) R(j, K) { sum+=A[i][M-K+j]; Q.push({A[i][M-K+j]+A[i][j], i}), Q.pop(); } vector<int> C(N); int l=0; while(Q.size()) sum-=Q.top().x, C[Q.top().i]++, Q.pop(); auto nxt=[&](int& i) { return i=i+1==K ? 0 : i+1; }; R(i, N) { fill(begin(A[i]), end(A[i]), -1); R(j, C[i]) A[i][j]=nxt(l); int r=l; R(j, K-C[i]) A[i][M-j-1]=nxt(r); } 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...