이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
struct ins {
int val, sidx, lidx, idx;
};
bool cmp(ins &x, ins &y) {
if(x.val == y.val) return x.idx < y.idx;
return x.val < y.val;
}
void allocate_tickets(vector<vector<int>> s);
int64_t find_maximum(int k, vector<vector<int>> x) {
int n = (int) x.size(), m = (int) x[0].size();
int64_t ans = 0;
vector<vector<int>> assign(n, vector<int>(m, -1));
for(int r = 0; r < k; r++) {
vector<ins> in;
for(int i = 0; i < n; i++) {
int mn = -1, mx = -1;
for(int j = 0; j < m; j++) {
if(x[i][j] == -1) continue;
if(mn == -1 || mx == -1)
mn = j, mx = j;
if(x[i][j] < x[i][mn]) mn = j;
if(x[i][j] > x[i][mx]) mx = j;
}
in.push_back({x[i][mn] + x[i][mx], mn, mx, i});
}
sort(in.begin(), in.end(), cmp);
for(int i = 0; i < n; i++) {
if(i < n / 2) {
ans -= x[in[i].idx][in[i].sidx];
x[in[i].idx][in[i].sidx] = -1;
assign[in[i].idx][in[i].sidx] = r;
}
else {
ans += x[in[i].idx][in[i].lidx];
x[in[i].idx][in[i].lidx] = -1;
assign[in[i].idx][in[i].lidx] = r;
}
}
}
allocate_tickets(assign);
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... |