This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "tickets.h"
using namespace std;
const int N = 1505;
long long dp[N][N];
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector <vector <int>> ans(n, vector <int>(m, -1));
for(int i = 1; i <= n; ++i) {
for(int j = 0; j <= n; ++j) {
if(j == 0) dp[i][j] = dp[i - 1][j] - x[i - 1][0];
else dp[i][j] = max(dp[i - 1][j] - x[i - 1][0], dp[i - 1][j - 1] + x[i - 1][m - 1]);
}
}
for(int i = n, j = (n + 1) / 2; i >= 1; --i) {
if(dp[i][j] == dp[i - 1][j] - x[i - 1][0]) {
ans[i - 1][0] = 0;
}
else if(dp[i][j] == dp[i - 1][j - 1] + x[i - 1][m - 1]) {
ans[i - 1][m - 1] = 0;
j--;
}
}
allocate_tickets(ans);
return dp[n][(n + 1) / 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... |