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 ff first
#define ss second
using namespace std;
typedef pair<int,int> pii;
const int N = 1550;
int L[N],R[N];
int ptL[N],ptR[N];
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>> ans(n,vector<int>(m,-1));
long long sum=0;
vector<pii> vals;
for(int i=0;i<n;i++){
ptL[i]=0,ptR[i] = m-1;
L[i] = 0;
R[i] = k;
for(int j=0;j<k;j++){
vals.push_back(pii(x[i][j] + x[i][m-k+j],i));
}
}
sort(vals.begin(),vals.end());
for(int i=0;i<n*k/2;i++){
auto it = vals[i];
L[it.second]++;
R[it.second]--;
}
for(int r=0;r<k;r++){
vector<pii> pos;
for(int i=0;i<n;i++){
pos.push_back(pii(R[i],i));
}
sort(pos.begin(),pos.end(),[&](pii a,pii b){
if(a.ff ==0 && b.ff==0)return a < b;
if(a.ff == 0)return false;
if(b.ff == 0)return true;
return a < b;
});
for(int i=0;i<n;i++){
int id = pos[i].second;
if(i < n/2){
// R:
R[id]--;
sum += x[id][ptR[id]];
ans[id][ptR[id]--] = r;
}else{
L[id]--;
sum -= x[id][ptL[id]];
ans[id][ptL[id]++] = r;
}
}
}
allocate_tickets(ans);
return sum;
}
# | 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... |