This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
continue;
}
if(t[i2]==m-i+1){
t[i2]--,il--;
ans[i2-1][r[i2].fi++]=i;
continue;
}
zos.push_back(i2);
}
for(auto u:zos){
if(il>0){
t[u]--,il--;
ans[u-1][r[u].fi++]=i;
}else{
il++;
ans[u-1][r[u].se--]=i;
}
}
}
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... |