题目链接

错误的贪了一下,然后D了两下就过了。注意是不上升和不下降。。不是上升和下降。。

 #include <cstring>
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
#define INF 100000000
int p[];
int dp[];
int o1[];
int o2[];
int main()
{
int a,b,i,n;
scanf("%d%d",&a,&b);
n = b - a + ;
for(i = ;i <= n;i ++)
scanf("%d",&p[i]);
o1[] = o2[] = ;
for(i = ;i <= n;i ++)
{
if(p[i] >= p[i-])
o1[i] = o1[i-];
else
o1[i] = i;
if(p[i] <= p[i-])
o2[i] = o2[i-];
else
o2[i] = i;
}
for(i = ;i <= n;i ++)
{
dp[i] = min(dp[o1[i]-],dp[o2[i]-]) + ;
}
printf("%d\n",dp[n]);
return ;
}

URAL 1346. Intervals of Monotonicity(DP)的更多相关文章

  1. ural 1346. Intervals of Monotonicity

    1346. Intervals of Monotonicity Time limit: 1.0 secondMemory limit: 64 MB It’s well known that a dom ...

  2. 1346. Intervals of Monotonicity(dp)

    1346 简单dp #include <iostream> #include<cstdio> #include<cstring> #include<algor ...

  3. URAL 1658. Sum of Digits(DP)

    题目链接 隔了一年零三个月,重新刷URAL,这题挺麻烦的输出路径.输出路径挺扯的,乱写了写乱改改就A了...我本来想用很靠谱,记录每一条路径的,然后输出最小的,结果Tle,然后我使劲水水又过了一组,发 ...

  4. URAL 1776 C - Anniversary Firework DP

    C - Anniversary FireworkTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/c ...

  5. Ural 1073 Square Country (DP)

    题目地址:Ural 1073 DP水题.也能够说是背包. #include <iostream> #include <cstdio> #include <string&g ...

  6. bzoj 1814 Ural 1519 Formula 1 插头DP

    1814: Ural 1519 Formula 1 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 942  Solved: 356[Submit][Sta ...

  7. 【BZOJ1814】Ural 1519 Formula 1 插头DP

    [BZOJ1814]Ural 1519 Formula 1 题意:一个 m * n 的棋盘,有的格子存在障碍,求经过所有非障碍格子的哈密顿回路个数.(n,m<=12) 题解:插头DP板子题,刷板 ...

  8. CodeForces - 367E:Sereja and Intervals(组合数&&DP)

    Sereja is interested in intervals of numbers, so he has prepared a problem about intervals for you. ...

  9. Ural 1183 Brackets Sequence(区间DP+记忆化搜索)

    题目地址:Ural 1183 最终把这题给A了.. .拖拉了好长时间,.. 自己想还是想不出来,正好紫书上有这题. d[i][j]为输入序列从下标i到下标j最少须要加多少括号才干成为合法序列.0< ...

随机推荐

  1. Delphi版本顺序

    1.02.03.04.05.06.07.08.0200520062007 现在应该又出新的版本了

  2. poj 3264:Balanced Lineup(线段树,经典题)

    Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 32820   Accepted: 15447 ...

  3. Swing布局基础

    虽然很简单,但还是记录一下,以备复查. 1.BorderLayout ,这是JFrame的默认布局方式,基于此的新组件,例如BUTTON,可以放在东西南北中的某一个位置,如果不指定,则默认是中央.中央 ...

  4. OGG异常处理

    ALTER REPLICAT LCMA1REP,BEGIN NOW 从最新的trail文件开始读取 ALTER REPLICAT LCMA1REP,EXTSEQNO 191(对应的 trail的序号 ...

  5. oracle pctfree和pctused详解

    一.建立表时候,注意PCTFREE参数的作用 PCTFREE:为一个块保留的空间百分比,表示数据块在什么情况下可以被insert,默认是10,表示当数据块的可用空间低于10%后,就不可以被insert ...

  6. ThinkPHP的field方法的用法总结

    ThinkPHP的连贯操作方法中field方法有很多的使用技巧,field方法主要目的是标识要返回或者操作的字段,下面详细道来. .用于查询 在查询操作中field方法是使用最频繁的. $Model- ...

  7. 关于socket——SO_SNDBUF and SO_RECVBUF

    转自:http://blog.csdn.net/wf1982/article/details/38871521 参见 http://stackoverflow.com/questions/425741 ...

  8. 编辑login.sql进行sqlplus登陆设置

    执行SQLPLUS登录到SQL 界面时候,就会自动的加载 $ORACLE_HOME/sqlplus/admin 中的login.sql(若没有则加载glogin.sql) 这里面的东西 是根据自己的爱 ...

  9. win8.1/win10 UEFI + GPT 安装(测试机型:华硕S56CM)

    本教程简要介绍在UEFI 启动模式下在GPT分区表中,最简单的方法安装 Windows 10 x64 位系统.(并非傻瓜教程,安装者总要有一定的经验基础)下面先简单介绍一下UEFI和GTP. UEFI ...

  10. 智能车学习(十一)——陀螺仪学习

    一.学习说明 感觉就是配置I2C通信,然后直接移植51代码... 二.代码分享: 1.头文件: #ifndef I2C_GYRO_H_ #define I2C_GYRO_H_ /*********** ...