# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
705832 | finn__ | Carnival Tickets (IOI20_tickets) | C++17 | 481 ms | 54812 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));
vector<size_t> assigned_low(k, 0);
for (size_t i = 0; i < x.size(); i++)
{
size_t low = y[i], up = k - y[i];
for (size_t j = 0; j < k; j++)
{
if (assigned_low[j] < x.size() / 2 && low)
a[i][--low] = j, assigned_low[j]++;
else
a[i][x[i].size() - up--] = 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... |