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 "holiday.h"
using namespace std;
#define ll long long int
vector<bool> visited;
ll solve(vector<vector<ll>> &dp, int c, int d, int n, int attraction[])
{
if(d==0)
return 0;
if(dp[c][d]!=-1)
return dp[c][d];
ll nb = 0;
if(c>0)
nb = max(nb, solve(dp, c-1, d-1, n, attraction));
if(c<n-1)
nb = max(nb, solve(dp, c+1, d-1, n, attraction));
visited[c] = true;
nb = max(nb, attraction[c] + solve(dp, c, d-1, n, attraction));
visited[c] = false;
return dp[c][d] = nb;
}
long long int findMaxAttraction(int n, int start, int d, int attraction[])
{
vector<vector<ll>> dp(n, vector<ll>(d+1, -1));
visited.assign(n, false);
ll res = solve(dp, start, d, n, attraction);
return res;
}
# | 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... |