# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
705842 | finn__ | Carnival Tickets (IOI20_tickets) | C++17 | 765 ms | 60520 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 "tickets.h"
#include <bits/stdc++.h>
using namespace std;
long long find_maximum(int k, vector<vector<int>> x)
{
long long value = 0;
for (size_t i = 0; i < x.size(); i++)
for (size_t j = 0; j < k; j++)
value -= x[i][j];
vector<size_t> y(x.size(), k);
priority_queue<pair<int64_t, size_t>> q;
for (size_t i = 0; i < x.size(); i++)
q.emplace(x[i][k - 1] + x[i].back(), i);
for (size_t z = 0; z < x.size() * k / 2; z++)
{
auto const [d, i] = q.top();
q.pop();
value += d;
y[i]--;
if (y[i])
q.emplace(x[i][y[i] - 1] + x[i][x[i].size() - (k - y[i] + 1)], i);
}
vector<vector<int>> a(x.size(), vector<int>(x[0].size(), -1));
for (size_t j = 0; j < k; j++)
{
vector<pair<size_t, size_t>> colors;
for (size_t i = 0; i < x.size(); i++)
colors.emplace_back(y[i], i);
sort(colors.begin(), colors.end());
for (size_t i = 0; i < x.size() / 2; i++)
a[colors[i].second][x[i].size() - ((k - j) - colors[i].first)] = j;
for (size_t i = x.size() / 2; i < x.size(); i++)
a[colors[i].second][--y[colors[i].second]] = j;
}
allocate_tickets(a);
return value;
}
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... |