#include <bits/stdc++.h>
#include "tickets.h"
using namespace std;
using ll = long long;
ll find_maximum(int k, vector<vector<int>> x) {
int n = x.size(), m = x[0].size();
vector<vector<ll>> delta(n, vector<ll>(k));
ll sm = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < k; j++) {
sm -= x[i][j];
}
for(int j = 0; j < k; j++) {
delta[i][j] = x[i][m - j - 1] + x[i][k - j - 1];
}
}
vector<int> pos(n), neg(n, k);
priority_queue<pair<ll, int>> pq;
for(int i = 0; i < n; i++) {
pq.push({delta[i][pos[i]], i});
}
for(int i = 0; i < n / 2 * k; i++) {
sm += pq.top().first;
int j = pq.top().second;
pq.pop();
pos[j]++;
neg[j]--;
if(pos[j] < k) pq.push({delta[j][pos[j]], j});
}
vector<vector<int>> s(n, vector<int>(m, -1));
for(int i = 0; i < k; i++) {
int negcnt = 0;
for(int j = 0; j < n; j++) {
if(pos[j] == 0) {
neg[j]--;
s[j][neg[j]] = i;
negcnt++;
}
}
for(int j = 0; j < n; j++) {
if(negcnt < n / 2 && neg[j] > 0) {
neg[j]--;
s[j][neg[j]] = i;
negcnt++;
} else {
s[j][m - pos[j]] = i;
pos[j]--;
}
}
}
allocate_tickets(s);
return sm;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
432 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Runtime error |
1 ms |
436 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
436 KB |
There is no ticket of color 3 on day 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
432 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
964 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Runtime error |
1 ms |
436 KB |
Execution killed with signal 6 |
9 |
Halted |
0 ms |
0 KB |
- |