이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include <algorithm>
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
std::vector<std::vector<int>> answer;
for (int i = 0; i < n; i++) {
std::vector<int> row(m);
for (int j = 0; j < m; j++) {
if (j < k) {
row[j] = j;
} else {
row[j] = -1;
}
}
answer.push_back(row);
}
allocate_tickets(answer);
// calculate return value
long long maximum = 0;
std::vector<std::vector<int>> rounds(k);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
int r = answer[i][j];
if (r != -1) {
rounds[r].push_back(x[i][j]);
}
}
}
for (int i = 0; i < k; ++i) {
std::sort(rounds[i].begin(), rounds[i].end());
int b = rounds[i][n/2];
for (int j = 0; j < n; ++j) {
if (rounds[i][j] < b) {
maximum += b - rounds[i][j];
}
else {
maximum += rounds[i][j] - b;
}
}
}
return maximum;
}
# | 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... |