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>
typedef long long ll;
#define MP make_pair
using namespace std;
long long find_maximum(int k, vector<vector<int>> a) {
int n = a.size();
int m = a[0].size();
ll ans = 0;
vector<vector<int>> answer(n, vector<int>(m, -1));
for (int it = 0; it < k; it++) {
vector<pair<pair<ll, int>, pair<int, int>>> v;
for (int i = 0; i < n; i++) {
int l = -1, r = -1;
for (int j = 0; j < m; j++){
if (answer[i][j] != -1) continue;
if (l == -1 || a[i][j] < a[i][l]) l = j;
if (r == -1 || a[i][j] > a[i][r]) r = j;
}
answer[i][r] = it;
ans += a[i][r];
v.emplace_back(MP(-a[i][r] - a[i][l], i), MP(l, r));
}
sort(v.rbegin(), v.rend());
for (int i = 0; i < n / 2; i++) {
ans += v[i].first.first;
answer[v[i].first.second][v[i].second.second] = -1;
answer[v[i].first.second][v[i].second.first] = it;
}
}
allocate_tickets(answer);
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... |