# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
426834 | zoooma13 | Carnival Tickets (IOI20_tickets) | C++14 | 2 ms | 716 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
#include "tickets.h"
using namespace std;
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
assert(m == k);
vector <array <int ,3>> all; //{val ,color ,index}
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
all.push_back({x[i][j] ,i ,j});
sort(all.begin() ,all.end());
int64_t tot = 0;
vector<vector<int>> answer(n ,vector<int>(m ,-1));
set <int> mex[n];
for(int i = 0; i < k; i++)
for(int c = 0; c < n; c++)
mex[c].insert(i);
vector <int> sizes(k);
set <int> mexsizes;
for(int i = 0; i < k; i++)
mexsizes.insert(i);
for(int i = 0; i < (int)all.size()/2; i++){
tot -= all[i][0];
int p = max(*mex[all[i][1]].begin() ,*mexsizes.begin());
sizes[p]++;
if(sizes[p] == n/2)
mexsizes.erase(p);
mex[all[i][1]].erase(p);
answer[all[i][1]][all[i][2]] = p;
}
for(int i = (int)all.size()/2; i < all.size(); i++){
tot += all[i][0];
int p = *mex[all[i][1]].begin();
mex[all[i][1]].erase(p);
answer[all[i][1]][all[i][2]] = p;
}
allocate_tickets(answer);
return tot;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |