이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
long long find_maximum(int k, vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector <vector <int>> ans(n, vector <int> (m, -1));
ll sum = 0;
vector <multiset<pair<int,int>>> rows(n);
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
rows[i].insert({x[i][j], j});
}
}
for (int i = 0; i < k; i++){
ll cur = 0;
vector <pair<ll, int>> ticket;
for (int j = 0; j < n; j++){
pair<int, int> l = *rows[j].begin();
pair<int, int> r = *rows[j].rbegin();
cur = -l.first - r.first;
ticket.push_back({cur, j});
cur += r.first;
}
sort(ticket.begin(), ticket.end(), greater<pair<ll, int>>());
for (int j = 0; j < n/2; j++){
cur += ticket[j].first;
int pos = ticket[j].second;
pair<int, int> ans_pos = *rows[pos].begin();
ans[pos][ans_pos.second] = i;
}
for (int j = 0; j < n; j++){
pair<int, int> ans_pos = *rows[j].begin();
pair<int, int> ans_pos_r = *rows[j].rbegin();
if (ans[j][ans_pos.second] != i){
ans[j][ans_pos_r.second] = i;
}
}
for (int j = 0; j < n; j++){
pair<int, int> l = *rows[j].begin();
pair<int, int> r = *rows[j].rbegin();
rows[j].erase(l);
rows[j].erase(r);
}
sum = max(sum, cur);
}
allocate_tickets(ans);
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... |