이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long find_maximum(int k, std::vector<std::vector<int>> d) {
int N=d.size();
int M=d[0].size();
for(int i=0;i<N;i++) {
for(int j=0;j<M;j++) {
assert(d[i][j]<=1 && 0<=d[i][j]);
}
}
vector<int> vals;
for(int j=0;j<M;j++) {
int s=0;
for(int i=0;i<N;i++) s+=d[i][j];
vals.push_back(min(s,N-s));
}
int sum=0;
for(int j=M-1;j>=M-k;j--) sum+=vals[j];
int curOpt=sum, opt=-1;
for(int j=0;j<k;j++) {
// [0,j] U [M-k+j+1,M-1]
if(j>=M-k+j+1) break;
sum+=vals[j];
sum-=vals[M-k+j];
if(sum<curOpt) {
curOpt=sum;
opt=j;
}
}
vector<vector<int>> s(N,vector<int>(M,-1));
int cnt=0;
for(int j=0;j<=opt;j++) {
for(int i=0;i<N;i++) s[i][j]=cnt;
cnt++;
}
for(int j=M-1;j>M-k+opt;j--) {
for(int i=0;i<N;i++) s[i][j]=cnt;
cnt++;
}
allocate_tickets(s);
return curOpt;
}
# | 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... |