이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "tickets.h"
using namespace std;
#define ll long long
#define sz(a) (int)a.size()
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define forn(i, n) for(int i=0;i < n; ++i)
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size(), m = x[0].size();
std::vector<std::vector<int>> answer(n, vector<int>(m, -1));
vector<int> use_left(n, 0), r(n, m - 1);
set<pair<int, int>> s;
ll ans = 0;
for(int i = 0; i < n; ++i) {
s.insert({x[i][0] + x[i][m - k], i});
}
for(int t = 0; t < n * k / 2; ++t) {
int i = (*s.begin()).second; s.erase(s.begin());
if(++use_left[i] < k) {
s.insert({x[i][use_left[i]] + x[i][m - k + use_left[i]], i});
}
}
for(int kk = 0; kk < k; ++kk) {
vector<pair<int, int>> a;
for(int i = 0; i < n; ++i) a.pb({use_left[i], i});
sort(rall(a));
for(int j = 0; j < n / 2; ++j) {
int i = a[j].second;
assert(use_left[i]);
ans -= x[i][use_left[i] - 1];
answer[i][--use_left[i]] = kk;
}
for(int j = n / 2; j < n; ++j) {
int i = a[j].second;
ans += x[i][r[i]];
answer[i][r[i]--] = kk;
}
}
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... |