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>
#include "tickets.h"
using namespace std;
const int MAXN = 1505;
int l[MAXN], r[MAXN];
long long find_maximum(int k, vector<vector<int> >v) {
int n = v.size();
int m = v[0].size();
vector<vector<int> >s;
vector<int>aux(m, -1);
for (int i = 0; i < n; ++i) {
s.push_back(aux);
r[i] = m - 1;
}
long long ans = 0;
while (k--) {
vector<pair<int, int> >srt(n);
for (int i = 0; i < n; ++i)
srt[i] = {-(v[i][r[i]] + v[i][l[i]]), i};
sort(srt.begin(), srt.end());
for (int i = 0; i < n / 2; ++i) {
ans += v[srt[i].second][r[srt[i].second]];
s[srt[i].second][r[srt[i].second]--] = k + 1;
}
for (int i = n / 2; i < n; ++i) {
ans -= v[srt[i].second][l[srt[i].second]];
s[srt[i].second][l[srt[i].second]++] = k + 1;
}
}
allocate_tickets(s);
return ans;
}
/*int main() {
freopen("date.in", "r", stdin);
freopen("date.out", "w", stdout);
int n, m, k;
cin >> n >> m >> k;
vector<vector<int> >v;
for (int i = 0; i < n; ++i) {
vector<int>g(m);
for (int j = 0; j < m; ++j)
cin >> g[j];
v.push_back(g);
}
cout << find_maximum(k, v);
return 0;
}*/
# | 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... |