# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
543542 | sliviu | Carnival Tickets (IOI20_tickets) | C++17 | 652 ms | 51332 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;
using ll = long long;
ll find_maximum(int k, vector<vector<int>> x) {
int n = x.size(), m = x[0].size();
ll ans = 0;
vector<int> pos(n, k - 1);
vector<vector<int>> sol(n, vector<int>(m, -1));
priority_queue<pair<int, int>> PQ;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < k; ++j)
ans -= x[i][j];
PQ.emplace(x[i][k - 1] + x[i][m - 1], i);
}
for (int i = 0; i < n * k / 2; ++i) {
auto [s, j] = PQ.top();
PQ.pop();
ans += s;
if (--pos[j] >= 0)
PQ.emplace(x[j][pos[j]] + x[j][m - k + pos[j]], j);
}
for (int i = 0, l = 0, r = k - 1; i < n; ++i) {
for (int j = 0; j <= pos[i]; ++j)
sol[i][j] = l, l = (l + 1) % k;
for (int j = m - 1; j > m - k + pos[i]; --j)
sol[i][j] = l, l = (l + 1) % k;
}
allocate_tickets(sol);
return ans;
}
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... |