#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=1505;
pair<ll, int> dp[nx][nx];
long long find_maximum(int k, std::vector<std::vector<int>> x) {
ll n = x.size();
ll m = x[0].size();
vector<vector<int>> res(n, vector<int> (m, -1));
for (int i=1; i<=n; i++) dp[0][i].first=-1e18;
for (int i=1; i<=n; i++)
{
for (int j=0; j<=i; j++)
{
dp[i][j].first=-1e18;
if (j!=0) dp[i][j]=max(dp[i][j], {dp[i-1][j-1].first-x[i-1][0], 1});
if (j!=i) dp[i][j]=max(dp[i][j], {dp[i-1][j].first+x[i-1][m-1], 0});
}
}
auto cur=dp[n][n/2];
int cj=n/2;
for (int i=n; i>=1; i--)
{
//printf("here %d %d %d\n", i, cj, cur.second);
if (cur.second) res[i-1][0]=0;
else res[i-1][m-1]=0;
if (cur.second) cur=dp[i-1][--cj];
else cur=dp[i-1][cj];
}
allocate_tickets(res);
return dp[n][n/2].first;
}
# |
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 |
Correct |
3 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
8540 KB |
Output is correct |
6 |
Correct |
8 ms |
36064 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 |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
2 ms |
2648 KB |
Output is correct |
5 |
Correct |
17 ms |
11520 KB |
Output is correct |
6 |
Correct |
411 ms |
108336 KB |
Output is correct |
# |
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 |
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 |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
8540 KB |
Output is correct |
6 |
Correct |
8 ms |
36064 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
2 ms |
2648 KB |
Output is correct |
11 |
Correct |
17 ms |
11520 KB |
Output is correct |
12 |
Correct |
411 ms |
108336 KB |
Output is correct |
13 |
Incorrect |
0 ms |
348 KB |
There is no ticket of color 0 on day 1 |
14 |
Halted |
0 ms |
0 KB |
- |