Submission #302679

#TimeUsernameProblemLanguageResultExecution timeMemory
302679cgiosyCarnival Tickets (IOI20_tickets)C++17
100 / 100
963 ms53552 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; 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}; } fill(begin(A[i]), end(A[i]), -1); } sort(begin(B), end(B)); vector<int> C(N); int l=0; R(i, X) sum-=B[i].x, C[B[i].i]++; R(i, N) { R(j, C[i]) A[i][j]=++l%=K; int r=l; R(j, K-C[i]) A[i][M-j-1]=++r%=K; } 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...