이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
long long find_maximum(int K, std::vector<std::vector<int>> x)
{
int N = x.size();
int M = x[0].size();
ll value = 0;
vvi ans(N, vi(M, -1));
vector<set<pii>> stuff(N);
for (int i = 0; i < N; ++i)
for (int j = 0; j < M; ++j)
stuff[i].insert({x[i][j], j});
for (int k = 0; k < K; ++k)
{
vpii choose;
for (int i = 0; i < N; ++i)
choose.push_back({stuff[i].begin()->first + stuff[i].rbegin()->first, i});
sort(all(choose));
for (int j = sz(choose) - 1; j >= sz(choose) / 2; --j)
{
int i = choose[j].second;
value += stuff[i].rbegin()->first;
ans[i][stuff[i].rbegin()->second] = k;
stuff[i].erase(--stuff[i].end());
}
for (int j = sz(choose) / 2 - 1; j >= 0; --j)
{
int i = choose[j].second;
value -= stuff[i].begin()->first;
ans[i][stuff[i].begin()->second] = k;
stuff[i].erase(stuff[i].begin());
}
}
allocate_tickets(ans);
return value;
}
# | 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... |