이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |