이 제출은 이전 버전의 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();
int m = x[0].size();
std::vector<std::vector<int>> answer(n, vector<int>(m, -1));
deque<pair<int, int>> d[n];
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j) {
d[i].pb({x[i][j], j});
}
sort(all(d[i]));
}
ll ans = 0;
for(int kk = 0; kk < m; ++kk) {
priority_queue<pair<int, int>> q;
forn(i, n) q.push({d[i].front().first + d[i].back().first, i});
for(int j = 0; j < sz(q) / 2; ++j) {
int i = q.top().second;
q.pop();
answer[i][d[i].back().second] = kk;
ans += d[i].back().first;
d[i].pop_back();
}
for(int j = 0; j < sz(q) / 2; ++j) {
int i = q.top().second;
q.pop();
answer[i][d[i].front().second] = kk;
ans -= d[i].front().first;
d[i].pop_front();
}
}
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... |