이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define X first
#define Y second
#define ALL(v) v.begin(),v.end()
#define SZ(a) ((int)a.size())
#define pb push_back
const ll INF=1e18;
ll find_maximum(int k, vector<vector<int>> x)
{
int n = x.size();
int m = x[0].size();
int tar=n*k/2;
ll rt=0;
vector<vector<int>> answer(n,vector<int>(m,-1));
vector<int> cnt(n,0),num(n,0),nw(n,0),tp(n,0);
for(int i=0;i<n;++i)
for(int j=0;j<k;++j)
if(x[i][j]!=0||tar==0)
{
cnt[i]=k-j;
break;
}
else
--tar;
for(int i=0;i<n&&tar;++i)
if(tar>=cnt[i])
tar-=cnt[i],cnt[i]=0;
else
cnt[i]-=tar,tar=0;
for(int i=0;i<n;++i)
{
for(int j=0;j<k-cnt[i];++j)
rt-=x[i][j];
for(int j=m-cnt[i];j<m;++j)
rt+=x[i][j];
}
for(int i=0;i<n;++i)
nw[i]=k-cnt[i],num[i]=i,tp[i]=cnt[i];
for(int i=0;i<k;++i)
{
sort(ALL(num),[&](int a,int b){return cnt[a]>cnt[b];});
for(int j=0;j<n/2;++j)
answer[num[j]][m-tp[num[j]]+(--cnt[num[j]])]=i;
for(int j=n/2;j<n;++j)
answer[num[j]][--nw[num[j]]]=i;
}
allocate_tickets(answer);
return rt;
}
# | 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... |