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>
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();
vector<int> ord;
for(int i=0;i<N;i++) ord.push_back(i);
sort(ord.begin(),ord.end(),[&](int i, int j) {
return d[i]<d[j];
});
vector<vector<int>> s(N,vector<int>(M,-1));
vector<pair<int,int>> vals;
for(int j=0;j<M;j++) {
int s=0;
for(int i=0;i<N/2;i++) s+=d[ord[i]][j];
for(int i=N/2;i<N;i++) s+=d[ord[i]][M-j-1];
s=min(s,N-s);
vals.push_back({s,j});
}
sort(vals.rbegin(),vals.rend());
ll ans=0;
for(int j=0;j<k;j++) {
ans+=vals[j].first;
for(int i=0;i<N/2;i++) s[ord[i]][vals[j].second]=j;
for(int i=N/2;i<N;i++) s[ord[i]][M-vals[j].second-1]=j;
}
allocate_tickets(s);
return ans;
}
# | 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... |