Eternal Reality


Time Limit: 2 Seconds                                      Memory Limit: 65536 KB


In Academy City, most students have special abilities. Such as Railgun, Teleport, Telekinesis, AIM Stalker and so on. Here, AIM (An Involuntary Movement) is a term used to refer to the phenomenon in which an esper involuntarily produces an invisible energy field around the esper. Different students have different type of AIM dispersion field, so they also have different level of abilities.

Of course, a higher level students can often deal with more issues than a lower level students. To classify the students in Academy City, there are 7 levels in total:

Level Term Description
Level 0 Person with No Powers Most students of this level can't keep up at school. They might possess some degree of power, but unable to truly control it.
Level 1 Person with Low Powers Powers of the degree to bend a spoon, many students belong here.
Level 2 Person with Unusual Powers Just like Level 1, powers are not very useful in everyday life.
Level 3 Person with Strong Powers The degree when powers are considered convenient in everyday life, ability-wise this is the Level when one starts to be treated as part of the elite.
Level 4 Person with Great Powers Powers of an extent that their owner acquires tactical value of a military force.
Level 5 Person with Super Powers Powers of an extent that their owner can fight alone against a military force on equal terms.
Level 6 Person with Absolute Powers Powers of an extent that they're considered immeasurable. However, no one can achieve this level, even with the help of Level Upper (it has no effect on persons with super powers). Since this, many institutions have been doing long-term researches about it, such as the Radio Noise Project.

You are a student of level L in Academy City and you are going to take part in a sports competition. The competition consists of N consecutive matches. If you want to get a point in the i-th match, your must reach at least Ai level. According to the rules, you must compete in all matches one by one.

To tell the truth, it won't be easy to compete with so many high-level opponents. Fortunately, you got a special item called Level Upper. Generally, it can increase your level by 1 for a short time. If you use the Level Upper before the i-th match, it's effect will last during the matches [i, i + X - 1]. But it also has a side effect that will make your level become 0 during the matches [i + X, i + X + Y - 1]. After the side effect ends, your level will return to L and you can use the Level Upper again.

Please calculate the maximal points you can get if you properly use the Level Upper.

Input

There are multiple test cases (plenty of small cases with several large cases). For each test case:

The first line contains four integers L (0 <= L <= 5), N, X and Y (1 <= N, X, Y <= 100). The next line contains N integers Ai (0 <= Ai <= 6).

Output

For each test case, output the maximal points you can get.

Sample Input

3 6 1 2
1 3 4 5 6 4

Sample Output

4

Hint

Read the problem description carefully.

 #include<stdio.h>
#include<string.h> using namespace std; int flag1[]; // 第i关不用技能是否可行
int flag2[]; // 第i关用技能是否可行
int flag3[]; // 第i关是否为0
int flag[][]; // 表示第i关j状态是否可行
int dp[][]; // 第i关的状态为j的最大过关数 // 这里的状态范围为 [0, x+y] ,分为三类
// [0] 正常状态, [1,x] 使用技能+1状态,[x+1,x+y] 技能恢复中能力值为0状态 int max(int a, int b) {
return a > b ? a : b;
} int main(int argc, char *argv[])
{
int l, n, x, y;
while(scanf("%d %d %d %d",&l, &n, &x, &y) == )
{
memset(flag1, , sizeof(flag1));
memset(flag2, , sizeof(flag2));
memset(flag3, , sizeof(flag3));
memset(flag, , sizeof(flag));
memset(dp, , sizeof(dp));
int tmp;
for(int i = ; i <= n; i++)
{
scanf("%d",&tmp);
if(l >= tmp) flag1[i] = ;
if(l + >= tmp && l != ){ // 能力值为5,技能+1过关,不可行
flag2[i] = ;
}
if(tmp == ) flag3[i] = ;
}
flag[][] = ;
for(int i = ; i <= n; i++) {
for(int j = ; j <= x + y; j++) {
if((j == || j == x + y) && flag[i-][j]) {
//如果前一个状态为 0 或 x+y 并且 前一关状态j可行
//那么下一个状态可以用技能到状态1或不用技能到状态0
dp[i][] = max(dp[i][], dp[i-][j] + flag1[i]);//不用技能
dp[i][] = max(dp[i][], dp[i-][j] + flag2[i]);//用技能
flag[i][] = flag[i][] = ;
}
else if(j > && j < x + y && flag[i-][j]) {
//当前状态为 >0 && <x+y 说明已经用过技能
//那么下一个状态只能为 [2, x+y] 范围内
//那么将前一个状态j可以分成 [1,x) 和 [x, x+y) 考虑
if(j < x) {
dp[i][j+] = max(dp[i][j+], dp[i-][j] + flag2[i]); //必须用技能
}
else{
dp[i][j+] = max(dp[i][j+], dp[i-][j] + flag3[i]); //技能冷却中,能力值为0
}
flag[i][j+] = ;
}
}
}
int ans = ;
for(int i = ; i <= x + y; i++) {
ans = max(ans, dp[n][i]);
}
printf("%d\n",ans);
}
return ;
}

ZOJ 3741 Eternal Reality的更多相关文章

  1. ZOJ3741 状压DP Eternal Reality

    E - Eternal Reality Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu S ...

  2. VR ( Virtual Reality )、AR(Augmented Reality)、MR(Mix Reality)和CR(Cinematic Reality)是什么鬼?

    整个社会对虚拟现实的研究和开发源于上个世纪六十年代,计算机图形学.人机接口技术.图像处理与模式识别.多传感技术.语音处理与音响技术.高性能计算机系统.人工智能等领域在之后半个世纪取得了长足的发展为虚拟 ...

  3. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  4. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

  5. ZOJ Problem Set - 1394 Polar Explorer

    这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...

  6. ZOJ Problem Set - 1392 The Hardest Problem Ever

    放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...

  7. ZOJ Problem Set - 1049 I Think I Need a Houseboat

    这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...

  8. ZOJ Problem Set - 1006 Do the Untwist

    今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...

  9. ZOJ Problem Set - 1001 A + B Problem

    ZOJ ACM题集,编译环境VC6.0 #include <stdio.h> int main() { int a,b; while(scanf("%d%d",& ...

随机推荐

  1. getopt()函数

    在讨论这个函数之前我们先理解两个概念:选项及其参数 gcc -o program program.c 在上述命令中 -o 就是其选项 program就是参数. getopt(): 头文件: #incl ...

  2. Fast InvSqrt()(平方根倒数速算法)

    浮点数的平方根倒数常用于计算正规化矢量.3D图形程序需要使用正规化矢量来实现光照和投影效果,因此每秒都需要做上百万次平方根倒数运算,而在处理坐标转换与光源的专用硬件设备出现前,这些计算都由软件完成,计 ...

  3. 简单的BFS学习笔记

    什么是BFS传送门. 今天学习BFS,加油! 先定义个数组: struct Node{ int a=0; int b=0; int step=0; }; int map[5][4]={//地图 0,0 ...

  4. BZOJ 2726: [SDOI2012]任务安排( dp + cdq分治 )

    考虑每批任务对后面任务都有贡献, dp(i) = min( dp(j) + F(i) * (T(i) - T(j) + S) ) (i < j <= N)  F, T均为后缀和. 与j有关 ...

  5. Linux学习之scp命令

    scp是secure copy的简写,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且scp传输是加密的,可能会稍微影响一下速度.当你服务器 ...

  6. 使用fastcgi_cache加速网站

    为了提高网站的性能缓存是一把利器,nginx中可以配置fastcig_cache来缓存不需要实时获取的数据实现动静分离,nginx.conf配置如下: http {     -     fastcgi ...

  7. EBS 开发中如何动态启用和禁止请求(Current Request)的参数

    EBS 开发中如何动态启用和禁止请求(Current Request)的参数 (版权声明,本人原创或者翻译的文章如需转载,如转载用于个人学习,请注明出处:否则请与本人联系,违者必究) 我们可以使用依赖 ...

  8. <a>标签中 href="/" 和 hideFocus="true"

    一:href="/" 连接到根目录 这是相对路径的根目录表示方法 可以写为 http://class.qq.com/">腾讯精品课 (绝对路径写法) 也可以为 腾讯 ...

  9. hdu 2828 Lamp 重复覆盖

    题目链接 给n个灯和m个开关, 每个灯可以由若干个开关控制, 每个开关也可以控制若干个灯, 问你能否找到一种开关的状态, 使得所有的灯都亮. 将灯作为列, 然后把每个开关拆成两行, 开是一行, 关是一 ...

  10. C语言实践——学生信息管理

    这是本人做的第一个实践项目,用的知识都是书上有的,没有很多很复杂的知识 同时因为没有学习 C语言 图形方面的知识,所以界面做得很丑,暂时先这样吧 源文件: #include <stdio.h&g ...