이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
typedef long long ll;
#define MP make_pair
using namespace std;
long long find_maximum(int k, vector<vector<int>> a) {
int n = a.size();
int m = a[0].size();
ll ans = 0;
vector<vector<int>> answer(n, vector<int>(m, -1));
for (int it = 0; it < k; it++) {
vector<pair<pair<ll, int>, pair<int, int>>> v;
for (int i = 0; i < n; i++) {
int l = -1, r = -1;
for (int j = 0; j < m; j++){
if (answer[i][j] != -1) continue;
if (l == -1 || a[i][j] < a[i][l]) l = j;
if (r == -1 || a[i][j] > a[i][r]) r = j;
}
answer[i][r] = it;
ans += a[i][r];
v.emplace_back(MP(-a[i][r] - a[i][l], i), MP(l, r));
}
sort(v.rbegin(), v.rend());
for (int i = 0; i < n / 2; i++) {
ans += v[i].first.first;
answer[v[i].first.second][v[i].second.second] = -1;
answer[v[i].first.second][v[i].second.first] = it;
}
}
allocate_tickets(answer);
return ans;
}
# | 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... |