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 "bits/stdc++.h"
#include "tickets.h"
using namespace std;
#define int long long
long long find_maximum(int32_t k,vector<vector<int32_t>> x){
int n = x.size();
int m = x[0].size();
vector<vector<int32_t>> vis(n,vector<int32_t>(m,-1));
long long fin = 0;
for(int i = 0;i<k;i++){
int mi[n],ma[n];
vector<array<int,5>> v;
long long overall = 0;
for(int j = 0;j<n;j++){
mi[j] = 1e18;
ma[j] = -1e18;
int MI = 0;
int MA = 0;
for(int w = 0;w<m;w++){
if(vis[j][w]!=-1)continue;
if(mi[j]>x[j][w]){
mi[j] = x[j][w];
MI = w;
}if(ma[j]<x[j][w]){
ma[j] = x[j][w];
MA = w;
}
}
v.push_back({mi[j],ma[j],MI,MA,j});
}
sort(v.begin(),v.end());
priority_queue<array<int,4>> pq;
for(auto j:v){
vis[j[4]][j[3]] = i;
overall+=j[1];
pq.push({-j[1]-j[0],j[2],j[3],j[4]});
}
int nah = n/2;
while(nah--){
vis[pq.top()[3]][pq.top()[2]] = -1;
vis[pq.top()[3]][pq.top()[1]] = i;
overall+=pq.top()[0];
pq.pop();
}
fin+=overall;
}
allocate_tickets(vis);
return fin;
}
| # | 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... |