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"
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
const int N=3020;
ll INF=-1e9;
ll dp[N][N][2],a[N];int n,s;
ll d(int x,int y,int z)
{
if(y<0)return INF;
if(x==-1||x==n)return 0;
if(y==0)return 0;
ll &u=dp[x][y][z];
if(u!=-1)return u;
u=a[x];
if(z==0)
{
u=max(d(x-1,y-2,z)+a[x],u);
u=max(d(x-1,y-1,z),u);
u=max(u,d(s+1,y-(s-x),1));
u=max(u,d(s+1,y-(s-x)-1,1)+a[x]);
return u;
}
u=max(d(x+1,y-1,z),d(x+1,y-2,z)+a[x]);
return u;
}/*
ll d1(int x,int y,int z)
{
if(y<0)return INF;
if(x==-1||x==n)return 0;
if(y==0)return 0;
ll &u=dp[x][y][z];
if(u!=-1)return u;
u=a[x];
if(z==0)
{
u=max(d1(x+1,y-2,z)+a[x],u);
u=max(d1(x+1,y-1,z),u);
u=max(u,d1(s-1,y-abs(s-x),1));
u=max(u,d1(s-1,y-abs(s-x)-1,1)+a[x]);
return u;
}
u=max(d1(x-1,y-1,z),d1(x-1,y-2,z)+a[x]);
return u;
}*/
long long int findMaxAttraction(int N, int start, int D, int A[])
{
memset(dp,-1,sizeof dp);
s=start;
n=N;
for(int i=0;i<n;i++)
{
a[i]=A[i];
}
ll u= d(start,D,0);
memset(dp,-1,sizeof dp);
//u=max(u,d1(start,D,0));
return u;
}
# | 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... |