이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |