This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |