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, vector<vector<int>> x) {
int n = (int)x.size();
int m = (int)x[0].size();
vector<vector<int>> ans(n, vector<int>(m, -1));
vector<pair<int, int>> rng(n, {0, m-1});
ll res = 0;
for(int r = 0; r < k; r++){
vector<pair<int, int>> v(n);
for(int i = 0; i < n; i++){
v[i] = {x[i][rng[i].first] + x[i][rng[i].second], i};
res -= x[i][rng[i].first];
}
sort(v.begin(), v.end());
for(int i = n - 1; i >= n/2; i--){
int ind = v[i].second;
ans[ind][rng[ind].second] = r;
rng[ind].second--;
res += v[i].first;
}
for(int i = 0; i < n/2; i++){
int ind = v[i].second;
ans[ind][rng[ind].first] = r;
rng[ind].first++;
}
}
allocate_tickets(ans);
return res;
}
# | 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... |