#include "tickets.h"
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
void allocate_tickets(vector<vector<int>> _d) ;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<std::vector<int>> answ(n , vector<int> (m , -1));
vector<pair<int , pair<int , int>>> vc;
for(int i = 0;i < n; ++ i){
for(int j = 0;j < m; ++ j) vc.push_back({x[i][j] , {i , j}});
}
sort(vc.begin() , vc.end());
long long ans = 0;
vector<int> cnt(n + 1);
int i = -1 , kol = 0;
while(kol < (n / 2) * k){
i ++;
cnt[vc[i].se.fi] ++;
if(cnt[vc[i].se.fi] > k) continue ;
ans -= vc[i].fi;
answ[vc[i].se.fi][vc[i].se.se] = kol / (n / 2);
kol ++;
}
reverse(vc.begin() , vc.end());
i = -1 , kol = 0;
while(kol < (n / 2) * k){
i ++;
cnt[vc[i].se.fi] ++;
if(cnt[vc[i].se.fi] > k) continue ;
ans += vc[i].fi;
answ[vc[i].se.fi][vc[i].se.se] = kol / (n / 2);
kol ++;
}
allocate_tickets(answ);
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... |