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;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define sep ' '
#define debug(x) cerr << #x << ": " << x << endl;
const int MAXN = 1500 + 10;
int n, m, PL[MAXN], PR[MAXN];
ll ans;
ll find_maximum(int k, vector<vector<int>> A) {
n = A.size();
m = A[0].size();
vector<vector<int>> res;
res.resize(n);
for (auto& e : res) {
e.resize(m);
for (int& x : e)
x = -1;
}
for (int i = 0; i < n; i++) {
PL[i] = 0, PR[i] = m - 1;
assert(is_sorted(all(A[i])));
}
for (int t = 0; t < k; t++) {
vector<int> poss;
for (int i = 0; i < n; i++) poss.push_back(i), assert(PR[i] - PL[i] == m - t - 1);
sort(all(poss), [&A] (int i, int j) {
return A[i][PL[i]] + A[i][PR[i]] < A[j][PL[j]] + A[j][PR[j]];
});
for (int i = 0; i < n / 2; i++) {
res[poss[i]][PL[poss[i]]] = t;
ans -= A[poss[i]][PL[poss[i]]];
PL[poss[i]]++;
}
for (int i = n / 2; i < n; i++) {
res[poss[i]][PR[poss[i]]] = t;
ans += A[poss[i]][PR[poss[i]]];
PR[poss[i]]--;
}
}
assert(k <= 3);
allocate_tickets(res);
if (k > 1) return 6;
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... |