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;
struct Srt {
int s;
int i, j;
bool operator <(const Srt& other) const {
return s < other.s;
}
};
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;
}
vector<Srt>srt;
long long ans = 0;
for (int i = 0; i < n; ++i) {
for (int j = r[i]; j >= r[i] - k + 1; --j) {
ans += v[i][j];
s[i][j] = r[i] - 1 - j;
}
for (int j = 0; j + m - k < m; ++j)
srt.push_back({v[i][j] + v[i][j + m - k], i, j});
}
sort(srt.begin(), srt.end());
for (int i = 0; i < n * k / 2; ++i) {
ans -= srt[i].s;
int val = s[srt[i].i][srt[i].j + m - k];
s[srt[i].i][srt[i].j + m - k] = -1;
s[srt[i].i][srt[i].j] = val;
}
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... |