Submission #1058690

#TimeUsernameProblemLanguageResultExecution timeMemory
1058690idasCarnival Tickets (IOI20_tickets)C++17
14 / 100
281 ms57844 KiB
#include "tickets.h" #include "bits/stdc++.h" #define FOR(i, begin, end) for(int i=(begin); i<(end); i++) #define le(x) ((x)[((int)(x).size())-1]) #define sz(x) ((int)((x).size())) #define pb push_back #define s second #define f first using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; const int MxN=1510, INF=1e9; int n, m, cn[MxN], l[MxN], r[MxN]; long long find_maximum(int k, std::vector<std::vector<int>> x) { n=sz(x); m=sz(x[0]); FOR(i, 0, n) r[i]=m-1; FOR(i, 0, n) FOR(j, 0, m) cn[i]+=x[i][j]; vector b(n, vector(m, -1)); int ans=0; FOR(R, 0, k) { vector<pii> inf; FOR(i, 0, n) inf.pb({cn[i],i}); sort(inf.begin(), inf.end()); FOR(i, 0, n/2) { int in=inf[i].s; if(m-R-cn[in]>0) { b[in][l[in]++]=R; } else { ans--; cn[in]--; b[in][r[in]--]=R; } } FOR(i, n/2, n) { int in=inf[i].s; if(cn[in]>0) { ans++; cn[in]--; b[in][r[in]--]=R; } else { b[in][l[in]++]=R; } } } allocate_tickets(b); return ans; } /* 2 3 2 0 2 5 1 1 3 4 2 1 5 9 1 4 3 6 2 7 4 4 1 0 1 2 9 4 4 4 5 3 3 3 7 3 4 4 4 4 2 1 0 10 1 5 0 6 0 6 4 4 1 0 1 2 9 7 7 7 7 7 7 7 7 7 7 7 7 8 2 1 1 9 0 10 2 3 3 4 6 8 1 5 0 2 3 4 4 3 2 0 1 1 1 1 1 0 0 1 0 0 0 4 2 2 0 1 0 1 0 0 1 1 4 2 1 0 1 0 0 0 0 1 1 4 3 2 0 0 0 0 1 1 0 1 1 1 1 1 */
#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...