이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "tickets.h"
using std::vector;
using std::array;
using std::pair;
using std::tuple;
using ll = long long;
ll find_maximum(int K, vector<vector<int>> X) {
const int N = X.size();
const int M = X[0].size();
ll score = 0;
vector<int> small(N, K);
std::priority_queue<pair<int, int>> heap;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < K; ++j) {
score -= X[i][j];
}
heap.emplace(X[i][M - 1] + X[i][K - 1], i);
}
for (int k = 0; k < N * K / 2; ++k) {
const auto [x, i] = heap.top();
heap.pop();
score += x;
small[i] -= 1;
if (small[i] > 0) {
heap.emplace(X[i][M - K + small[i] - 1] + X[i][small[i] - 1], i);
}
}
vector alloc(N, vector(M, -1));
int a = 0, b = K - 1;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < small[i]; ++j) {
alloc[i][j] = a;
a = (a + 1) % K;
}
for (int j = 0; j < K - small[i]; ++j) {
alloc[i][M - j - 1] = b;
b = (b + K - 1) % K;
}
}
allocate_tickets(alloc);
return score;
}
# | 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... |