Submission #308313

#TimeUsernameProblemLanguageResultExecution timeMemory
308313sofapudenCarnival Tickets (IOI20_tickets)C++14
27 / 100
735 ms51448 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll find_maximum(int k, vector<vector<int>> x) { priority_queue<pair<int,int>> PQ; ll n = x.size(); ll m = x[0].size(); vector<vector<int>> ans(n, vector<int> (m,-1)); vector<int> go(n,0); ll out = 0; for(int i = 0; i < n; ++i){ for(int j = 0; j < k; ++j){ out-=x[i][j]; } PQ.push({x[i][k-1]+x[i][m-1], i}); } int cn = 0; while(cn++ < (n/2)*k){ auto now = PQ.top(); out+=now.first; PQ.pop(); if(++go[now.second] != k){ PQ.push({x[now.second][k-1-go[now.second]]+x[now.second][m-1-go[now.second]],now.second}); } } cn = 0; for(int i = 0; i < n; ++i){ for(int j = 0; j < k-go[i]; ++j){ ans[i][j] = cn++; cn%=k; } if(go[i] == 0)continue; iota(ans[i].begin()+m-go[i], ans[i].end(), cn%k); } allocate_tickets(ans); return out; }
#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...