이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
typedef pair<int, int> pii;
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> ans = vector<vector<int>>(n, vector<int>(m, -1));
set<pii> t[n];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
t[i].insert({x[i][j], j});
int win = 0;
for (int r = 0; r < k; r++) {
vector<pii> c;
for (int j = 0; j < n; j++) {
c.push_back({t[j].begin()->first + t[j].rbegin()->first, j});
// cout << c.back().first << ' ';
}
// cout << endl;
sort(c.begin(), c.end());
for (int i = 0; i < n / 2; i++) {
int col = c[i].second;
int ix = t[col].begin()->second;
win -= x[col][ix];
ans[col][ix] = r;
t[col].erase({x[col][ix], ix});
}
for (int i = n / 2; i < n; i++) {
int col = c[i].second;
int ix = t[col].rbegin()->second;
win += x[col][ix];
ans[col][ix] = r;
t[col].erase({x[col][ix], ix});
}
}
allocate_tickets(ans);
return win;
}
# | 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... |