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;
long long res = 0;
vector<int> l, r;
vector<vector<int>> sg, ans;
set<pair<int, pair<int, int>>> prio;
long long find_maximum(int k, vector<vector<int>> x) {
n = x.size();
m = x[0].size();
l = vector<int>(n, 0);
r = vector<int>(n, m - 1);
sg = vector<vector<int>>(n, vector<int>(m, 0));
ans = vector<vector<int>>(n, vector<int>(m, -1));
for (int i = 0; i < n; i++)
{
for (int j = 0; j < k; j++)
{
sg[i][j] = -1;
int s, p;
s = x[i][j];
p = x[i][m - k + j];
prio.insert(make_pair(-s - p, make_pair(i, j)));
//res -= s;
}
}
int cnt = 0;
for (auto it = prio.begin(); cnt < n * k / 2; cnt++, it++)
{
auto v = *it;
//res -= v.first;
auto pos = v.second;
sg[pos.first][pos.second] = 0;
sg[pos.first][m - k + pos.second] = 1;
}
for (int t = 0; t < k; t++)
{
int plus = 0;
for (int i = 0; i < n; i++)
{
if (sg[i][l[i]] != -1)
{
plus++;
}
}
for (int i = 0; i < n; i++)
{
if (sg[i][l[i]] != -1)
{
ans[i][r[i]] = t;
res += x[i][r[i]];
r[i]--;
}
else if (sg[i][r[i]] != 1)
{
ans[i][l[i]] = t;
res -= x[i][l[i]];
l[i]++;
}
else
{
if (plus < n / 2)
{
plus++;
ans[i][r[i]] = t;
res += x[i][r[i]];
r[i]--;
}
else
{
ans[i][l[i]] = t;
res -= x[i][l[i]];
l[i]++;
}
}
}
}
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... |