이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1500;
using ll = long long;
int gde[MAXN+5];
int levo[MAXN+5];
int desno[MAXN+5];
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;
for (int i = 0; i < n; i++) {
std::vector<int> row(m);
for (int j = 0; j < m; j++) {
row[j] = -1;
}
answer.push_back(row);
}
ll res = 0;
priority_queue <pair <int, int>> pq;
for(int i=0; i<n; i++){
for(int j=0; j<k; j++) res -= x[i][j];
gde[i] = k-1;
pq.push({x[i][m-1] + x[i][gde[i]], i});
}
int turns = n*k/2;
while(turns--){
pair <int, int> pr = pq.top();
res += pr.first;
int i = pr.second;
pq.pop();
gde[i]--;
if(gde[i] >= 0) pq.push({x[i][m-1-(k-1-gde[i])] + x[i][gde[i]], i});
}
set <pair <int, int>> q;
for(int i=0; i<n; i++){
levo[i] = gde[i];
desno[i] = m-1;
q.insert({levo[i], i});
}
for(int turn=0; turn<k; turn++){
vector <pair <int, int>> posle;
int times = n/2;
while(times--){
int i = q.begin()->second;
q.erase(q.begin());
answer[i][desno[i]] = turn;
desno[i]--;
posle.push_back({levo[i], i});
}
times = n/2;
while(times--){
int i = q.rbegin()->second;
q.erase(*q.rbegin());
answer[i][levo[i]] = turn;
levo[i]--;
posle.push_back({levo[i], i});
}
for(auto c : posle) q.insert(c);
}
allocate_tickets(answer);
return res;
}
# | 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... |