이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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] - 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... |