1346. Intervals of Monotonicity(dp)
简单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 ;
}
1346. Intervals of Monotonicity(dp)的更多相关文章
- ural 1346. Intervals of Monotonicity
1346. Intervals of Monotonicity Time limit: 1.0 secondMemory limit: 64 MB It’s well known that a dom ...
- 【LeetCode】435. Non-overlapping Intervals 解题报告(Python)
[LeetCode]435. Non-overlapping Intervals 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemi ...
- TCSRM 593 div2(1000)(dp)
Problem Statement The pony Rainbow Dash wants to choose her pet. There are N animals who want t ...
- Intervals POJ - 3680 (MCMF)
给你一些区间,每个区间都有些价值.取一个区间就能获得对应的价值,并且一个点不能覆盖超过k次,问你最大的价值是多少. 我们可以把这些区间放到一维的轴上去,然后我们可以把它看成一个需要从左到右的过程,然后 ...
- 【LeetCode】915. Partition Array into Disjoint Intervals 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/partitio ...
- TCSRM 591 div2(1000)(dp)
挺好的dp 因为有一点限制 必须任意去除一个数 总和就会小于另一个总和 换句话来说就是去除最小的满足 那么就都满足 所以是限制最小值的背包 刚开始从小到大定住最小值来背 TLE了一组数据 后来发现如果 ...
- URAL 1346. Intervals of Monotonicity(DP)
题目链接 错误的贪了一下,然后D了两下就过了.注意是不上升和不下降..不是上升和下降.. #include <cstring> #include <cstdio> #inclu ...
- 1741. Communication Fiend(dp)
刷个简单的DP缓缓心情 1A #include <iostream> #include<cstdio> #include<cstring> #include< ...
- [LeetCode]题解(python):056-Merge Intervals
题目来源 https://leetcode.com/problems/merge-intervals/ Given a collection of intervals, merge all overl ...
随机推荐
- UIWebView 需改userAgent 并且加载微信公共账号
需要注意的是需要获取原来的UIWebView的User-Agent,然后拼接上自己新的User-Agent,貌似直接替换原来的无效,另外,修改User-Agent之后重新创建UIWebView加载网页 ...
- get的四种请求形式
$_GET变量当用户以get方式请求页面并发送数据的时候,$_GET变量就存储了这些数据——get数据!get请求有4种形式:形式1:<form action=”abc.php” meth ...
- 微软职位内部推荐-Software Development Engineer II
微软近期Open的职位: Job Title:Software Development EngineerII Division: Server & Tools Business - Comme ...
- 第五周技术博客发表 web 网页开发
<html><head> <title> HTML</title></head><body > <h1>会员注册界面 ...
- POJ 3723 Conscription 最小生成树
题目链接: 题目 Conscription Time Limit: 1000MS Memory Limit: 65536K 问题描述 Windy has a country, and he wants ...
- execl执行解释器文件以及shell命令
问题描述: execl执行解释器文件以及shell命令 问题解决: 具体源文件:
- 本地不安装oracle-client,使用pl/sql developer连接数据库
一.问题描述 本地未安装oracle-client端,由于机器资源有限,希望通过pl/sql developer进行远程数据库连接.单纯的安装pl/sql developer无法远程连接数据库. 二. ...
- javascript积累
本来是java程序员,但是工作过程中总是遇到各种js的任务得完成,所以也得慢慢积累啊! 一.浏览器对象模型(Browser Object Model)BOM window对象:当前浏览器窗口 ...
- DelayedOperationPurgatory之DelayedOperation pool
purgatory就是炼狱的意思. 当一个DelayedOperation需要被delay时,它就被放到DelayedOperationPurgatory,相当于进行一个等待池.上一篇blog提到过, ...
- A Step-by-Step Guide to Your First AngularJS App
What is AngularJS? AngularJS is a JavaScript MVC framework developed by Google that lets you build w ...