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 <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(), x.end()
#include "tickets.h"
using namespace std;
const ll INF = 1e18;
long long find_maximum(int k, std::vector<std::vector<int>> a) {
int n = a.size();
int m = a[0].size();
if (m == 1) {
vector<int> x(n);
for (int i = 0; i < n; i++) x[i] = a[i][0];
sort(all(x));
ll ans = 0;
for (int i = 0; i < n / 2; i++) ans -= x[i];
for (int i = n / 2; i < n; i++) ans += x[i];
allocate_tickets(vector<vector<int>>(n, vector<int>(1)));
return ans;
}
if (k == 1) {
vector<int> x(n), y(n);
ll ans2 = 0;
for (int i = 0; i < n; i++) x[i] = a[i][0], y[i] = a[i][m-1], ans2 -= x[i];
vector<vector<int>> ans(n, vector<int>(m, -1));
vector<int> idx(n);
iota(all(idx), 0);
sort(all(idx), [&](int X, int Y) { return x[X] + y[X] > x[Y] + y[Y]; });
for (int i = 0; i < n; i++) ans[i][0] = 0;
for (int i = 0; i < n / 2; i++) {
int pos = idx[i];
ans2 += x[pos] + y[pos];
ans[pos][0] = -1, ans[pos][m-1] = 0;
}
allocate_tickets(ans);
return ans2;
}
}
Compilation message (stderr)
tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:39:1: warning: control reaches end of non-void function [-Wreturn-type]
39 | }
| ^
# | 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... |