이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> answer(n, vector<int>(m, -1));
int a[n], b[n];
for (int i = 0; i < n; i++)
{
a[i] = 0;
b[i] = m - 1;
}
long long ret = 0;
for (int g = 0; g < k; g++)
{
vector<bool>av(n, true);
int c = n / 2;
set<pair<int, int>, greater<pair<int, int>>>A;
for (int i = 0; i < n; i++)
A.insert({x[i][b[i]], i});
while (c--)
{
pair<int, pair<int, int>>mx = { -1, {0, 1}};
for (int i = 0; i < n; i++)
{
if (av[i] == false)
continue;
A.erase({x[i][b[i]], i});
int j = A.begin()->second;
mx = max(mx, {x[j][b[j]] - x[i][a[i]], {i, j}});
A.insert({x[i][b[i]], i});
}
ret += mx.first;
A.erase({x[mx.second.first][b[mx.second.first]], mx.second.first});
A.erase({x[mx.second.second][b[mx.second.second]], mx.second.second});
answer[mx.second.first][a[mx.second.first]] = g;
answer[mx.second.second][b[mx.second.second]] = g;
a[mx.second.first]++;
b[mx.second.second]--;
av[mx.second.first] = false;
av[mx.second.second] = false;
}
}
allocate_tickets(answer);
return ret;
}
| # | 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... |