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;
using ll = long long;
ll find_maximum(int K, vector<vector<int>> x) {
int N = x.size();
int M = x[0].size();
vector<tuple<int, int, int>> v;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
v.emplace_back(x[i][j], i, j);
}
}
sort(v.begin(), v.end());
vector f(N, vector<int>(M, -1));
ll ans = 0;
for (int i = 0; i < N * K / 2; i++) {
auto [t, x, y] = v[i];
ans -= t;
f[x][y] = 0;
}
for (int i = N * M - N * K / 2; i < N * M; i++) {
auto [t, x, y] = v[i];
ans += t;
f[x][y] = 1;
}
vector a(N, vector<int>(M, -1));
int s = 0, t = K - 1;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
if (f[i][j] == 0) {
a[i][j] = t--;
}
if (f[i][j] == 1) {
a[i][j] = s++;
}
if (t == -1) {
t = K - 1;
}
if (s == K) {
s = 0;
}
}
}
allocate_tickets(a);
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... |