이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
void allocate_tickets( std::vector<std::vector<int>> _x);
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
std::vector<std::vector<int>> answer(n,vector<int> (m,-1));
int r=0;
vector<pair<int,int>> q;
vector<pair<pair<int,int>,pair<int,int>>> add;
std::vector<int> p={};
for (int i = 0; i < n; i++) {
p.push_back(k-1);
for(int j=0;j<k;j++){
r-=x[i][j];answer[i][j]=1;
q.push_back({x[i][j]+x[i][m-(k-j)],add.size()});
add.push_back({{i,j},{i,m-(k-j)}});
}
}
sort(q.begin(),q.end());
int mn=10000000;
for(int z=n*k/2;z<n*k;z++){
r+=q[z].F;int i=q[z].S;
answer[add[i].F.F][add[i].F.S]=-1;
answer[add[i].S.F][add[i].S.S]=1;
mn=min(mn,x[add[i].S.F][add[i].S.S]);
}int d=-1;
for (int i = 0; i < n; i++){
int c=d+1;
for(int j=0;j<m;j++){
if(answer[i][j]==-1){
continue;
}
if(x[i][j]<mn)d=c;
answer[i][j]=c;
c=(c+1)%k;
}
}
allocate_tickets(answer);
return r;
}
# | 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... |