이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
#define se second
#define fi first
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int N=1e3+10;
int t[N];
pair<int,int> r[N];
ll find_maximum(int k, vector<vi> x) {
int n=x.size();
int m=x[0].size();
vector<vi> ans=x;
vector<pair<int,int>> pom;
for(int i=1;i<=n;i++){
r[i]={0,m-1};
for(int i2=1;i2<=m;i2++){
pom.push_back({x[i-1][i2-1],i});
}
}
sort(pom.begin(),pom.end());
ll res=0;
for(int i=0;i<(int)pom.size()/2;i++){
res-=pom[i].fi;
t[pom[i].se]++;
}
for(int i=(int)pom.size()/2;i<(int)pom.size();i++) res+=pom[i].fi;
for(int i=1;i<=k;i++){
int il=0;
vi zos;
for(int i2=1;i2<=n;i2++){
if(t[i2]==0){
il++;
ans[i2-1][r[i2].se--]=i-1;
continue;
}
if(t[i2]==m-i+1){
t[i2]--,il--;
ans[i2-1][r[i2].fi++]=i-1;
continue;
}
zos.push_back(i2);
}
for(auto u:zos){
if(il>0){
t[u]--,il--;
ans[u-1][r[u].fi++]=i-1;
}else{
il++;
ans[u-1][r[u].se--]=i-1;
}
}
}
allocate_tickets(ans);
return res;
}
# | 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... |