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 "mountains.h"
#include <vector>
#include <iostream>
using namespace std;
long long int dp[2005][2005],n;
int maximum_deevs(std::vector<int> y) {
n=y.size();
for(int i=0;i<n;i++)dp[i][i]=1;
for(int len=2;len<=n;len++)
{
for(int i=0;i<n;i++)
{
if(i+len-1>=n)break;
int r=i+len-1;
dp[i][r]=max(dp[i][r-1],dp[i+1][r]);
long long int p=0,ma=0;
for(int j=i;j<i+len;j++)
{
if(y[j]>ma)
{
ma=y[j];
p=j;
}
}
dp[i][r]=max(dp[i][p-1]+dp[p+1][r],dp[i][r]);
//cout<<i<<" "<<r<<" "<<dp[i][r]<<endl;
}
}
return dp[0][n-1];
}
# | 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... |