URAL 1346. Intervals of Monotonicity(DP)
错误的贪了一下,然后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)的更多相关文章
- ural 1346. Intervals of Monotonicity
1346. Intervals of Monotonicity Time limit: 1.0 secondMemory limit: 64 MB It’s well known that a dom ...
- 1346. Intervals of Monotonicity(dp)
1346 简单dp #include <iostream> #include<cstdio> #include<cstring> #include<algor ...
- URAL 1658. Sum of Digits(DP)
题目链接 隔了一年零三个月,重新刷URAL,这题挺麻烦的输出路径.输出路径挺扯的,乱写了写乱改改就A了...我本来想用很靠谱,记录每一条路径的,然后输出最小的,结果Tle,然后我使劲水水又过了一组,发 ...
- URAL 1776 C - Anniversary Firework DP
C - Anniversary FireworkTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/c ...
- Ural 1073 Square Country (DP)
题目地址:Ural 1073 DP水题.也能够说是背包. #include <iostream> #include <cstdio> #include <string&g ...
- 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 ...
- 【BZOJ1814】Ural 1519 Formula 1 插头DP
[BZOJ1814]Ural 1519 Formula 1 题意:一个 m * n 的棋盘,有的格子存在障碍,求经过所有非障碍格子的哈密顿回路个数.(n,m<=12) 题解:插头DP板子题,刷板 ...
- CodeForces - 367E:Sereja and Intervals(组合数&&DP)
Sereja is interested in intervals of numbers, so he has prepared a problem about intervals for you. ...
- Ural 1183 Brackets Sequence(区间DP+记忆化搜索)
题目地址:Ural 1183 最终把这题给A了.. .拖拉了好长时间,.. 自己想还是想不出来,正好紫书上有这题. d[i][j]为输入序列从下标i到下标j最少须要加多少括号才干成为合法序列.0< ...
随机推荐
- GMap.Net开发之在WinForm和WPF中使用GMap.Net地图插件
GMap.NET是什么? 来看看它的官方说明:GMap.NET is great and Powerful, Free, cross platform, open source .NET contro ...
- MS SQL 合并结果集并求和 分类: SQL Server 数据库 2015-02-13 10:59 92人阅读 评论(0) 收藏
业务情景:有这样一张表:其中Id列为表主键,Name为用户名,State为记录的状态值,Note为状态的说明,方便阅读. 需求描述:需要查询出这样的结果:某个人某种状态的记录数,如:张三,待审核记录数 ...
- [Linux] yum和apt-get用法及区别
一般来说著名的linux系统基本上分两大类: 1.RedHat系列:Redhat.Centos.Fedora等 2.Debian系列:Debian.Ubuntu等 RedHat 系列 1 常见的安装包 ...
- (译)【Unity教程】使用Unity开发Windows Phone上的横版跑酷游戏
译者注: 目前移动设备的跨平台游戏开发引擎基本都是采用Cocos2d-x或者Unity.一般而言2d用cocos2d-x 3d用unity,但是对于Windows Phone开发者, cocos2d- ...
- 5.linux内核模块基础,内核模块学习
linux内核模块基础 一.定义 Linux 内核的整体结构非常庞大,其包含的组件也非常多,如何使用这些组件呢: 方法 1:把所有的组件都编译进内核文件,即:zImage 或 bzImage,但这样会 ...
- C++ find 函数用法
头文件 #include <algorithm> 函数实现 template<class InputIterator, class T> InputIterator find ...
- apk 打包方式
1 项目-->Android tools -->Export Signed Application Package 2 在项目 manifest.xml文件下 单击“use the Ex ...
- DampView阻尼效果
阻尼效果即是图片向下拉动时会放大,松开会回弹 1.自定义一个DampView类,继承ScrollView 2.布局最外层必须是DampView,且DampView和要拉动的图片之间只能有一层layou ...
- 【框架】网络请求+Gson解析--Retrofit 2
其实内部是封装了Okhttp和Gson解析 public class CourseFragmentAPI { public static void get(String userId, BaseCal ...
- LoadRunner之安装、破解、汉化教程(一)
安装前,把所有的杀毒软件和防火墙关闭 安装前,把所有的杀毒软件和防火墙关闭 安装前,把所有的杀毒软件和防火墙关闭........ 注意事项: 安装前,把所有的杀毒软件和防火墙关闭. 若以前安装 ...