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;
using pii = pair<int,int>;
using ll = long long int;
#define pb push_back
#define F first
#define S second
ll find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<int> l(n,k-1),r(n,m),vec;
priority_queue<pii> pq;
vector<vector<int>> an(n,vector<int>(m,-1));
ll ans=0;
int rem=n*k/2;
for(int i=0; i<n; i++){
vec.pb(i);
for(int j=0; j<k; j++){
ans-=x[i][j];
}
pq.push({x[i][m-1]+x[i][k-1],i});
}
while(rem--){
auto [t,i]=pq.top();
pq.pop();
ans+=t;
l[i]--;
r[i]--;
if(l[i]>=0) pq.push({x[i][r[i]-1]+x[i][l[i]],i});
}
for(int i=0; i<k; i++){
sort(vec.begin(),vec.end(),[&](int &a, int &b){return l[a]>l[b];});
for(int j=0; j<n/2; j++){
an[vec[j]][l[vec[j]]]=i;
l[vec[j]]--;
}
for(int j=n/2; j<n; j++){
an[vec[j]][r[vec[j]]]=i;
r[vec[j]]++;
}
}
allocate_tickets(an);
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... |