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;
#define loop(x, i) for (int i = 0; i < (x); i++)
#define ALL(x) (x).begin(), x.end()
#define pb push_back
#define int long long
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<signed> vi32;
typedef vector<bool> vb;
typedef set<int> si;
typedef vector<vi> vvi;
typedef vector<vi32> vvi32;
typedef vector<si> vsi;
typedef vector<ii> vii;
typedef set<iii> siii;
int find_maximum(signed k, vvi32 x)
{
assert(k == 1);
int n = x.size();
int m = x[0].size();
vvi32 answer(n, vi32(m, -1));
siii opts;
loop(n, i)
{
opts.insert({x[i][0], i, 0});
opts.insert({x[i][m - 1], i, m - 1});
}
vi a;
loop(n / 2, iter)
{
{
auto [v, i, j] = *prev(opts.end());
answer[i][j] = 0;
a.pb(v);
opts.erase({x[i][m - 1], i, m - 1});
opts.erase({x[i][0], i, 0});
}
{
auto [v, i, j] = *opts.begin();
answer[i][j] = 0;
a.pb(v);
opts.erase({x[i][m - 1], i, m - 1});
opts.erase({x[i][0], i, 0});
}
}
sort(ALL(a));
int b = a[n / 2];
int res = 0;
for (int v : a)
res += abs(b - v);
allocate_tickets(answer);
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... |