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中的 ...
随机推荐
- 并发包之Future:代码级控制超时时间
先谢Doug Lea. 使用场景: 最近在做webservice调用的时候,发现一个问题,对方的webservice接口很不稳定,所以在获取的数据时候经常要等待很久才能把数据全部拉回来,甚至有时候直接 ...
- Android 遍历界面控件
//遍历界面上的控件 fubin.pan LinearLayout sLinerLayout = (LinearLayout)findViewById(R.id.layout_scr); for (i ...
- Docker大行其道—初识
导读 随着分布式.云计算.大数据的火热爆发,大量的云计算集群出现,光凭计算机硬件配置的已经无法再次一较高下,虚拟化成为其中最核心的技术.虚拟化既可以通过硬件模拟,也可以通过操作系统层面去实现,近年来热 ...
- iOS高级必备
1.你使用过Objective-C的运行时编程(Runtime Programming)么?如果使用过,你用它做了什么?你还能记得你所使用的相关的头文件或者某些方法的名称吗? Objecitve-C的 ...
- 秀尔算法:破解RSA加密的“不灭神话”
RSA加密 VS 秀尔算法 作为RSA加密技术的终结者——“太多运算,无法读取”的秀尔算法(Shor’s algorithm)不是通过暴力破解的方式找到最终密码的,而是利用量子计算的并行性,可以快速分 ...
- WinAPI: ExtCreateRegion - 区域变换
转载:http://www.cnblogs.com/del/archive/2008/06/03/1212534.html 相似函数: SetWorldTransform 本例效果图: 代码文件: u ...
- macosx zsh下安装rvm和ruby
1)curl -L get.rvm.io | bash -s stable 2)把下面一行加到~/.zshrc中: [[ -s "$HOME/.rvm/scripts/rvm" ] ...
- windows2003批量添加和导出所有ip
批量添加IP 在cmd命令行下运行: FOR /L %i IN (130,1,190) DO netsh interface ip add address "本地连接" 192.1 ...
- 奇怪的梦境(codevs 2833)
题目描述 Description Aiden陷入了一个奇怪的梦境:他被困在一个小房子中,墙上有很多按钮,还有一个屏幕,上面显示了一些信息.屏幕上说,要将所有按钮都按下才能出去,而又给出了一些信息,说明 ...
- javascript reduce map函数方法
retduce: 对数组中的所有元素调用指定的回调函数.该回调函数的返回值为累积结果,并且此返回值在下一次调用该回调函数时作为参数提供. 语法 array1.reduce(callbackfn ...