#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
long long ret = 0;
priority_queue<pair<int, int>> pq;
for (int i = 0; i < n; ++i) {
for (int j = m - 1; j >= m - k; --j) {
ret += x[i][j];
}
pq.emplace(-x[i][0] - x[i][m - k], i);
}
vector<int> t(n);
for (int cnt = 0; cnt < n * k / 2; ++cnt) {
auto [val, ind] = pq.top();
pq.pop();
cnt++;
ret += val;
t[ind]++;
if (t[ind] < k) {
pq.emplace(-x[ind][t[ind]] - x[ind][m - k + t[ind]], ind);
}
}
vector<int> c(n), c2(n);
for (int i = 0; i < n; ++i) {
c2[i] = m - k + t[i];
}
vector<vector<int>> answer(n, vector<int> (m, -1));
for (int round = 0; round < k; ++round) {
vector<int> ord(n);
iota(ord.begin(), ord.end(), 0);
sort(ord.begin(), ord.end(), [&](int i, int j) {
return t[i] - c[i] > t[j] - c[j];
});
for (int j = 0, taken = 0; j < (int) ord.size(); ++j) {
if (taken < n / 2) {
answer[ord[j]][c[ord[j]]] = round;
c[ord[j]]++;
taken++;
} else {
answer[ord[j]][c2[ord[j]]] = round;
c2[ord[j]]++;
}
}
}
allocate_tickets(answer);
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Contestant returned 1729378519 but the tickets gives a total value of 2119935063 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Contestant returned 2471397678 but the tickets gives a total value of 3556946529 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Contestant returned 6 but the tickets gives a total value of 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
There is no ticket of color 0 on day 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
There is no ticket of color 0 on day 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
There is no ticket of color 0 on day 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Contestant returned 1729378519 but the tickets gives a total value of 2119935063 |
3 |
Halted |
0 ms |
0 KB |
- |