이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "tickets.h"
using namespace std;
#define pb push_back
#define se second
#define fi first
long long find_maximum(int k, std::vector<std::vector<int>> x) {
long long n = x.size();
int m = x[0].size();
vector<vector<int>> ans(n,vector<int> (m,-1));
priority_queue<pair<long long,int>> pq;
long long res=0;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < k; ++j)
{
res-=x[i][j];
}
}
int l[n];
int r[n];
for (int i = 0; i < n; ++i)
{
l[i]=k-1;
r[i]=m-1;
pq.push({x[i][l[i]--]+x[i][r[i]--],i});
}
for (int i = 0; i < k*n/2; ++i)
{
auto cur=pq.top();
res+=cur.fi;
pq.pop();
if(l[cur.se]==-1||r[cur.se]==m-k-1) continue;
pq.push({x[cur.se][l[cur.se]--]+x[cur.se][r[cur.se]--],cur.se});
}
for (int i = 0; i < n; ++i)
{
int cnt=0;
for (int j = 0; j <= l[i]; ++j)
{
ans[i][j]=cnt++;
}
for (int j = r[i]+1; j < m; ++j)
{
ans[i][j]=cnt++;
}
}
allocate_tickets(ans);
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... |