#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);
}
int cnt = 0;
vector<int> t(n);
while (cnt < n * k / 2) {
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<bool> sub(n);
for (int j = 0, taken = 0; j < n; ++j) {
if (c[j] < t[j] && taken < n / 2) {
answer[j][c[j]] = round;
c[j]++;
taken++;
} else {
answer[j][c2[j]] = round;
c2[j]++;
}
}
}
allocate_tickets(answer);
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
16 ms |
2284 KB |
Output is correct |
6 |
Correct |
389 ms |
51332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
There is no ticket of color 3 on day 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Incorrect |
1 ms |
604 KB |
There is no ticket of color 48 on day 0 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Incorrect |
1 ms |
604 KB |
There is no ticket of color 48 on day 0 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
16 ms |
2284 KB |
Output is correct |
12 |
Correct |
389 ms |
51332 KB |
Output is correct |
13 |
Incorrect |
0 ms |
344 KB |
There is no ticket of color 3 on day 0 |
14 |
Halted |
0 ms |
0 KB |
- |