1346. Intervals of Monotonicity(dp)

1346

简单dp

1346. Intervals of Monotonicity(dp)1346. Intervals of Monotonicity(dp)
 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
using namespace std;
#define N 200010
int p[N],dp[N][];
int main()
{
int i,a,b;
scanf("%d%d",&a,&b);
for(i = ; i <= b-a+ ; i++)
scanf("%d",&p[i]);
dp[][] = ;
dp[][] = ;
for(i = ; i <= b-a+ ; i++)
{
if(p[i]>p[i-])
{
dp[i][] = min(dp[i-][]+,dp[i-][]);
dp[i][] = min(dp[i-][]+,dp[i-][]+);
}
else if(p[i]<p[i-])
{
dp[i][] = min(dp[i-][]+,dp[i-][]+);
dp[i][] = min(dp[i-][]+,dp[i-][]);
}
else
{
dp[i][] = min(dp[i-][],dp[i-][]+);
dp[i][] = min(dp[i-][],dp[i-][]+);
}
}
int ans = min(dp[b-a+][],dp[b-a+][]);
printf("%d\n",ans);
return ;
}
上一篇:Httptunnel教程


下一篇:iOS开发——语法OC篇&Block回顾