# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303079 | tutis | Carnival Tickets (IOI20_tickets) | C++17 | 1156 ms | 62500 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 <vector>
#include <bits/stdc++.h>
using namespace std;
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
bool vien = true;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (x[i][j] < 0 || x[i][j] > 1)
vien = false;
vector<vector<int>> answer(n, vector<int>(m, -1));
int mxp = n / 2 * k;
int P[n];
vector<pair<int, int>>A;
for (int i = 0; i < n; i++)
{
P[i] = 0;
for (int j = 0; j < k; j++)
A.push_back({x[i][k - 1 - j] + x[i][m - 1 - j], i});
}
sort(A.begin(), A.end(), greater<pair<int, int>>());
for (int i = 0; i < (int)A.size() / 2; i++)
P[A[i].second]++;
int a[n];
int b[n];
for (int i = 0; i < n; i++)
{
a[i] = 0;
b[i] = m - 1;
}
long long ret = 0;
for (int g = 0; g < k; g++)
{
pair<int, int>xx[n];
for (int i = 0; i < n; i++)
xx[i] = {P[i], i};
sort(xx, xx + n);
for (int i = 0; i < n / 2; i++)
{
int id = xx[i].second;
ret -= x[id][a[id]];
answer[id][a[id]] = g;
a[id]++;
}
for (int i = n / 2; i < n; i++)
{
int id = xx[i].second;
ret += x[id][b[id]];
answer[id][b[id]] = g;
b[id]--;
P[id]--;
}
}
allocate_tickets(answer);
return ret;
}
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... |