이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3F3F3F3F3F3F3F3F
long long find_maximum(int k, vector<vector<int>> x) {
assert(k == 1);
int n = x.size();
int m = x[0].size();
vector<vector<int>> answer(n, vector<int> (m, -1));
vector<vector<long long>> dp(n, vector<long long> (n / 2 + 5, -inf)), par(n, vector<long long> (n / 2 + 5, -1));
dp[0][0] = -x[0][0], dp[0][1] = x[0][1];
for (int i = 1; i < n; i++)
{
for (int j = 0; j <= n / 2; j++)
{
if (j)
{
if (dp[i - 1][j] - x[i][0] > dp[i - 1][j - 1] + x[i][m - 1])
{
dp[i][j] = dp[i - 1][j] - x[i][0];
par[i][j] = j;
}
else
{
dp[i][j] = dp[i - 1][j - 1] + x[i][m - 1];
par[i][j] = j - 1;
}
}
else
{
dp[i][j] = dp[i - 1][j] - x[i][0];
par[i][j] = j;
}
}
}
int i = n - 1, j = n / 2;
while (i >= 0)
{
if (!i)
{
if (j == 1) answer[i][m - 1] = 0;
else if (j == 0) answer[i][0] = 0;
else assert(0);
}
else
{
if (par[i][j] == j) answer[i][0] = 0;
else if (par[i][j] == j - 1) answer[i][m - 1] = 0;
else assert(0);
}
j = par[i][j];
i--;
}
allocate_tickets(answer);
return dp[n - 1][n / 2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |