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"holiday.h"
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;
const int N = 222;
const int D = 2*N + N/2;
ll dp[N][D];
ll findMaxAttraction(int n, int start, int d, int attraction[]) {
ll ans = 0;
for (int _ = 0 ; _ < 2 ; ++ _) {
for (int i = 0 ; i < N ; ++ i) for (int j = 0 ; j < D ; ++ j) {
dp[i][j] = 0;
}
for (int i = 0 ; i < n ; ++ i) {
for (int j = 0 ; j <= d ; ++ j) {
if (j > 0) dp[i][j] = max(dp[i][j], (ll)attraction[i]);
if (i > 0 && j > 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1]);
if (i > 0 && j > 1) dp[i][j] = max(dp[i][j], dp[i - 1][j - 2] + attraction[i]);
if (j > 0) dp[i][j] = max(dp[i][j], dp[i][j - 1]);
}
}
for (int i = start ; i < n ; ++ i) {
int x = d - (i - start);
if (x >= 0) ans = max(ans, dp[i][x]);
}
reverse(attraction, attraction + n);
start = n - start - 1;
}
return ans;
}
# | 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... |