ural 1247. Check a Sequence
1247. Check a Sequence
Memory limit: 64 MB
Input
Output
Samples
input | output |
---|---|
4 3 |
YES |
4 5 |
NO |
Problem Source: Ural State University Personal Programming Contest, March 1, 2003
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define For(i, s, t) for(int i = (s); i <= (t); i++)
#define Ford(i, s, t) for(int i = (s); i >= (t); i--)
#define Rep(i, t) for(int i = (0); i < (t); i++)
#define Repn(i, t) for(int i = ((t)-1); i >= (0); i--)
#define rep(i, x, t) for(int i = (x); i < (t); i++)
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair
inline void SetIO(string Name)
{
string Input = Name+".in",
Output = Name+".out";
freopen(Input.c_str(), "r", stdin),
freopen(Output.c_str(), "w", stdout);
} inline int Getint()
{
int Ret = ;
char Ch = ' ';
bool Flag = ;
while(!(Ch >= '' && Ch <= ''))
{
if(Ch == '-') Flag ^= ;
Ch = getchar();
}
while(Ch >= '' && Ch <= '')
{
Ret = Ret * + Ch - '';
Ch = getchar();
}
return Flag ? -Ret : Ret;
} const int N = ;
int n, m, Arr[N], Ans; inline void Input()
{
scanf("%d%d", &n, &m);
For(i, , n) scanf("%d", &Arr[i]);
} inline void Solve()
{
int Cnt = Arr[] - ;
Ans = Cnt;
For(i, , n)
{
Cnt = max(Cnt + Arr[i] - , Arr[i] - );
Ans = max(Ans, Cnt);
}
if(Ans <= m) puts("YES");
else puts("NO");
} int main()
{
#ifndef ONLINE_JUDGE
SetIO("F");
#endif
Input();
Solve();
return ;
}
ural 1247. Check a Sequence的更多相关文章
- 递推DP URAL 1081 Binary Lexicographic Sequence
题目传送门 题意:问第k个长度为n的01串是什么(不能有相邻的1) 分析:dp[i][0/1] 表示前i个,当前第i个放1或0的方案数,先预处理计算,dp[i][1]只能有dp[i-1][0]转移过来 ...
- URAL 1081 Binary Lexicographic Sequence
第13个位置第5个Bit :13>num[4] =>1 第四个bit 13-num[4]=5 :5<num[3] =>0 ,3-1 第三个Bit 5>num[2](3) ...
- URAL DP第一发
列表: URAL 1225 Flags URAL 1009 K-based Numbers URAL 1119 Metro URAL 1146 Maximum Sum URAL 1203 Scient ...
- myrocks复制中断问题排查
背景 mysql可以支持多种不同的存储引擎,innodb由于其高效的读写性能,并且支持事务特性,使得它成为mysql存储引擎的代名词,使用非常广泛.随着SSD逐渐普及,硬件存储成本越来越高,面向写优化 ...
- LevelDB源码剖析
LevelDB的公共部件并不复杂,但为了更好的理解其各个核心模块的实现,此处挑几个关键的部件先行备忘. Arena(内存领地) Arena类用于内存管理,其存在的价值在于: 提高程序性能,减少Heap ...
- Wide character in print at a2.pl line 6.
jrhapt01:/home/tomcat/test> cat a2.pl my $str="$ARGV[0]"; use Encode; use URI::Escape; ...
- encode_utf8 把字符编码成字节 decode_utf8解码UTF-8到字符
encode_utf8 $octets = encode_utf8($string); Equivalent to "$octets = encode("utf8", $ ...
- [Oracle][DATAGUARD] 关于确认LOGICAL STANDBY的同期状况的方法
Oracle的DATAGUARD环境,有PHYSICAL STANDBY和LOGICAL STANDBY两种.PHYSICAL STANDBY是传输REDO传到Standby端,然后由Standby端 ...
- LevelDB源码分析-MemTable
MemTable(db/memtable.h db/memtable.cc db/skiplist.h) LevelDB中存储在内存中的那部分KV数据都存储在memtable中,而memtable中的 ...
随机推荐
- jvm内存模型和内存分配
1.什么是jvm? (1)jvm是一种用于计算设备的规范,它是一个虚构出来的机器,是通过在实际的计算机上仿真模拟各种功能实现的. (2)jvm包含一套字节码指令集,一组寄存器,一个栈,一个垃圾回收堆和 ...
- Slider插件(滑动条,拉链)
Slider插件(滑动条,拉链) 下载地址:http://files.cnblogs.com/elves/Slider.rar 提示:微软AJAX插件中也带此效果!
- HDU 3998 Sequence(经典问题,最长上升子序列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3998 解题报告:求一个数列的最长上升子序列,并求像这样长的不相交的子序列最多有多少个. 我用的是最简单 ...
- node.js+websocket实现简易聊天室
(文章是从我的个人主页上粘贴过来的,大家也可以访问我的主页 www.iwangzheng.com) websocket提供了一种全双工客户端服务器的异步通信方法,这种通信方法使用ws或者wss协议,可 ...
- phpcms某处储存型XSS(demo+本地演示)
文章转载:http://www.myhack58.com/Article/html/3/7/2016/71726.htm 详细说明: demo+本地演示存在xss漏洞的地方在商务中心的商家资料的我的资 ...
- HDU3345广搜 (P,E,T,#)
War chess is hh's favorite game:In this game, there is an N * M battle map, and every player has his ...
- Ubuntu上安装gtk2.0不能安装的问题,“下列的软件包有不能满足的依赖关系”
zez@localhoss:~$ sudo apt-get install libgtk2.0-dev正在读取软件包列表... 完成正在分析软件包的依赖关系树 正在读取状态信息... 完成 ...
- Java字符串split函数的注意事项
Java字符串的split方法可以分割字符串,但和其他语言不太一样,split方法的参数不是单个字符,而是正则表达式,如果输入了竖线(|)这样的字符作为分割字符串,会出现意想不到的结果, 如, Str ...
- 使用git如何批量对文件进行rm操作
git add -A 它会把我们未通过 git rm 删除的文件全部stage 转自: http://segmentfault.com/q/1010000000095373
- 《ASP.NET1200例》嵌套在DataLisT控件中的其他服务器控件---DropDownList控件的数据绑定
aspx <script type="text/javascript"> function CheckAll(Obj) { var AllObj = document. ...