이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
#define va first
#define vb second
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MN = 1505;
int D[MN],U[MN],f[MN][MN];
bool cmp(int x, int y)
{
return D[x]<D[y];
}
ll find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
ll sum = 0;
vector<vector<int>> ans;
vector<int> row(m,-1);
for(int i=0; i<n; i++){
ans.push_back(row);
}
priority_queue<pii> PQ;
for(int i=0; i<n; i++){
D[i] = k-1;
U[i] = m;
PQ.emplace(x[i][U[i]-1]+x[i][D[i]],i);
}
for(int i=0; i<n*k/2; i++){
int j = PQ.top().vb;
PQ.pop();
U[j]--;
D[j]--;
if(D[j]>=0) PQ.emplace(x[j][U[j]-1]+x[j][D[j]],j);
}
vector<int> v(n);
for(int i=0; i<k; i++){
for(int j=0; j<n; j++) v[j] = j;
sort(all(v),cmp);
for(int j=0; j<n; j++){
if(j>=n/2){
int c = v[j];
ans[c][D[c]] = i;
sum -= x[c][D[c]];
D[c]--;
}
else{
int c = v[j];
ans[c][U[c]] = i;
sum += x[c][U[c]];
U[c]++;
}
}
}
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... |