#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,e) for (int i = s; i <= e; ++i)
typedef vector<int> vi;
long long find_maximum(int k, vector<vi> x) {
int n = x.size(), m = x[0].size();
long long ans = 0;
vector<vi> answer(n, vi(m, -1));
priority_queue<pair<int,int>> pq;
int used[n]={}, lo[n]={};
rep (i,0,n-1) {
rep (j,0,k-1) ans -= x[i][j];
pq.push({x[i][m-1]+x[i][k-1],i});
}
rep (i,1,n*k/2) {
int ma = pq.top().first, c = pq.top().second;
pq.pop();
ans += ma;
if (used[c]<k) {
++used[c];
if (used[c]<k) pq.push({x[c][m-1-used[c]]+x[c][k-1-used[c]],c});
}
}
rep (i,0,k-1) {
int cnt = 0;
rep (j,0,n-1) {
if (used[j] && cnt<n/2) {
++cnt;
answer[j][m-1-(--used[j])] = i;
}
else answer[j][lo[j]++] = i;
}
}
allocate_tickets(answer);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
25 ms |
2364 KB |
Output is correct |
6 |
Correct |
621 ms |
51332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Contestant returned 4 but the tickets gives a total value of 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
There is no ticket of color 3 on day 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
There is no ticket of color 3 on day 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
There is no ticket of color 3 on day 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
716 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
25 ms |
2364 KB |
Output is correct |
12 |
Correct |
621 ms |
51332 KB |
Output is correct |
13 |
Incorrect |
1 ms |
204 KB |
Contestant returned 4 but the tickets gives a total value of 6 |
14 |
Halted |
0 ms |
0 KB |
- |