이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "tickets.h"
using namespace std;
long long find_maximum(int k, std::vector<std::vector<int>> x)
{
int n = x.size(), m = x[0].size();
vector<vector<int> > ans(n, vector<int>(m, -1));
vector<pair<long long, pair<int, int> > > moo;
for (int e = 0; e < k; e++)
{
for (int i = 0; i < n; i++)
{
ans[i][e] = e;
moo.push_back({x[i][e] + x[i][e + m - k], {i, e}});
}
}
sort(moo.begin(), moo.end());
reverse(moo.begin(), moo.end());
for (int i = 0; i < n / 2 * k; i++)
{
int a = moo[i].second.first;
int b = moo[i].second.second;
int z = ans[a][b];
ans[a][b] = -1;
ans[a][b + m - k] = z;
}
allocate_tickets(ans);
long long res = 0;
vector<vector<int> > day(k);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (ans[i][j] != -1)
{
day[ans[i][j]].push_back(x[i][j]);
}
}
}
for (int i = 0; i < k; i++)
{
sort(day[i].begin(), day[i].end());
for (int j = 0; j < n / 2; j++)
{
res += day[i][j + n / 2] - day[i][j];
}
}
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... |