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>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define svec(x) sort(all(x))
#define press(x) x.erase(unique(all(x)), x.end());
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
const int INF=1e9;
const LL LLINF=1e18;
int n, m, k, re[1510], re2[1510], re3[1510], ans2[1510][1510];
LL arr[1510][1510], ans;
bool ch[1510];
priority_queue<pli> pq;
LL find_maximum(int _k, vector<vector<int> > x){
n=x.size();
m=x[0].size();
k=_k;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++)arr[i][j]=(LL)x[i-1][j-1];
}
for(int i=1; i<=n; i++){
for(int j=m-k+1; j<=m; j++)ans+=arr[i][j];
pq.push(mp(-arr[i][1]-arr[i][m-k+1], i));
re3[i]=m;
}
for(int i=1; i<=n*k/2; i++){
LL d=pq.top().F;
int nw=pq.top().S;
pq.pop();
ans+=d;
re[nw]++;
if(re[nw]<k)pq.push(mp(-arr[nw][re[nw]+1]-arr[nw][m-k+re[nw]+1], nw));
}
memset(ans2, -1, sizeof ans2);
int pv=0;
for(int i=1; i<=n; i++){
for(int j=1; j<=re[i]; j++){
ans2[i][j]=pv;
ch[pv]=1;
pv=(pv+1)%k;
}
int tmp=0;
for(int j=m-k+re[i]+1; j<=m; j++){
while(ch[tmp])tmp++;
ans2[i][j]=tmp++;
}
memset(ch, 0, sizeof ch);
}
vector<vector<int> > ret;
for(int i=1; i<=n; i++){
vector<int> vc(m);
for(int j=1; j<=m; j++)vc[j-1]=ans2[i][j];
ret.eb(vc);
}
allocate_tickets(ret);
return ans;
}
# | 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... |