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"
#include <vector>
using namespace std;
int n;
int m;
vector<pair<int, int>> all;
vector<int> l, r;
vector<vector<int>> ans;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
n = x.size();
m = x[0].size();
l = vector<int>(n, 0);
r = vector<int>(n, m - 1);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
all.push_back({x[i][j], i});
}
}
sort(all.begin(), all.end());
ans = vector<vector<int>>(n, vector<int>(m, -1));
long long res = 0;
for (int t = 0; t < k; t++)
{
vector<pair<int, int>> up;
long long sum = 0;
for (int i = 0; i < n; i++)
{
sum -= x[i][l[i]];
up.push_back({x[i][r[i]] + x[i][l[i]], i});
}
sort(up.begin(), up.end());
for (int i = 0; i < n; i++)
{
if (i >= n / 2)
{
ans[up[i].second][r[up[i].second]] = t;
sum += up[i].first;
r[up[i].second]--;
}
else
{
ans[up[i].second][l[up[i].second]] = t;
l[up[i].second]++;
}
}
res += sum;
}
allocate_tickets(ans);
return res;
}
# | 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... |