이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
#define int long long
int n = x.size();
int m = x[0].size();
vector<pair<int,int>> s(n);
vector<int> all, cnt(n);
for(int i = 0;i<n;i++) {
s[i] = pair{0, m-1};
}
vector<vector<int32_t>> res(n, vector<int32_t>(m, -1));
priority_queue<pair<int,int>> pq;
for(int i = 0;i<n;i++) {
pq.push({-x[i][m-k]-x[i][cnt[i]], i});
}
for(int _ = 0;_<(n*k)/2;_++) {
int i = pq.top().second;
pq.pop();
cnt[i]++;
if(m-k+cnt[i] < m) {
pq.push({{-x[i][m-k+cnt[i]]-x[i][cnt[i]]}, i});
}
}
long long sum=0;
for(int _ = 0;_<k;_++) {
vector<int> idxs(n);
iota(idxs.begin(), idxs.end(), 0);
sort(idxs.begin(), idxs.end(), [&](int a, int b) -> bool {
return cnt[a] < cnt[b];
});
vector<int> ans;
for(int i = 0;i<n/2;i++) {
sum+=x[idxs[i]][s[idxs[i]].second];
res[idxs[i]][s[idxs[i]].second--]=_;
}
for(int i = n/2;i<n;i++) {
// assert(cnt[idxs[i]]);
sum-=x[idxs[i]][s[idxs[i]].first];
cnt[idxs[i]]--;
res[idxs[i]][s[idxs[i]].first++]=_;
}
}
allocate_tickets(res);
#undef int
return sum;
}
# | 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... |