# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1039684 | amirhoseinfar1385 | 카니발 티켓 (IOI20_tickets) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1500+10;
long long n,m,all[maxn][maxn],last[maxn];
vector<vector<int>>res;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
n = x.size();
m = x[0].size();
res.resize(n,vector<int>(m));
for(long long i=0;i<n;i++){
for(long long j=0;j<m;j++){
all[i][j]=x[i][j];
res[i][j]=-1;
}
}
long long mainres=0;
priority_queue<pair<long long,long long>>pq;
for(int i=0;i<n;i++){
for(int j=m-1;j>=m-k;j--){
res[i][j]=1;
mainres+=all[i][j];
}
pq.push(make_pair(-all[i][m-k]-all[i][0],i));
}
for(int i=0;i<(n*k)/2;i++){
mainres+=pq.top().first;
auto x=pq.top().second;
pq.pop();
res[x][last[x]]=1;
res[x][m-k+last[x]]=-1;
last[x]++;
if(last[x]==k){
continue;
}
pq.push(make_pair(-all[x][last[x]]-all[x][m-k+last[x]],x));
}
for(int i=0;i<n;i++){
int cnt=0;
for(int j=0;j<last[i];j++){
res[i][j]=cnt;
cnt++;
}
for(int j=last[x];j<m-k+last[i];j++){
res[i][j]=-1;
}
for(int j=m-k+last[i];j<m;j++){
res[i][j]=cnt;
cnt++;
}
}
allocate_tickets(res);
return mainres;
}