이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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.resize(n, 0);
r.resize(n, m - 1);
sg.resize(n, vector<int>(m, 0));
ans.resize(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... |