ZOJ 3741 Eternal Reality
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的更多相关文章
- ZOJ3741 状压DP Eternal Reality
E - Eternal Reality Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu S ...
- VR ( Virtual Reality )、AR(Augmented Reality)、MR(Mix Reality)和CR(Cinematic Reality)是什么鬼?
整个社会对虚拟现实的研究和开发源于上个世纪六十年代,计算机图形学.人机接口技术.图像处理与模式识别.多传感技术.语音处理与音响技术.高性能计算机系统.人工智能等领域在之后半个世纪取得了长足的发展为虚拟 ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1392 The Hardest Problem Ever
放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...
- ZOJ Problem Set - 1049 I Think I Need a Houseboat
这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...
- ZOJ Problem Set - 1006 Do the Untwist
今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...
- ZOJ Problem Set - 1001 A + B Problem
ZOJ ACM题集,编译环境VC6.0 #include <stdio.h> int main() { int a,b; while(scanf("%d%d",& ...
随机推荐
- [转]取代cookie的网站追踪技术:”帆布指纹识别”初探
[前言] 一般情况下,网站或者广告联盟都会非常想要一种技术方式可以在网络上精确定位到每一个个体,这样可以通过收集这些个体的数据,通过分析后更加精准的去推送广告(精准化营销)或其他有针对性的一些活动.C ...
- C# datetimePicker控件格式设置
//必须先设置Format属性为Custom,然后才能自定义格式 this.dtPicker.Format = DateTimePickerFormat.Custom; this.dtPicker.C ...
- zoj 3471Most Powerful
题意:给n个atom(原子),每两个原子相碰会产生能量,不过每次碰撞会消失一个原子,而且不同原子碰撞,消失的原子不同,产生的能量也会不同,给出不同原子相碰撞产生的能量,求出能产生的最多能量. 状态DP ...
- ie6,ie7,ie8 css bug汇总以及兼容解决方法
1:li边距“无故”增加 任何事情都是有原因的,li边距也不例外. 先描述一下具体状况:有些时候li边距会突然增 加很多,值也不固定(只在IE6/IE7有这种现象),让人摸不着头脑,仔细“研究”发现是 ...
- codeforces 645C . Enduring Exodus 三分
题目链接 我们将所有为0的位置的下标存起来. 然后我们枚举左端点i, 那么i+k就是右端点. 然后我们三分John的位置, 找到下标为i时的最小值. 复杂度 $ O(nlogn) $ #include ...
- Silverlight并行下载与串行下载
思路清晰后仅仅只需百来行代码便可轻松编写出一套完整的资源动态下载组件- SerialDownloader和ParallelDownloader,它们共用一个完成资源表,且串行下载集成了优先机制(Dow ...
- NOI2013 Day2
NOI2013 Day2 矩阵游戏 题目描述:设矩阵\(F\) 求\(F[n][m](mod (10^9+7))\) solution: 这题可以求通项解决. 设\(X_i=F[i][m]\), \( ...
- openstack 升级设计要求的指导原则
不知道其他软件有没有类似的指导原则. Theory of Upgrade Grenade works under the following theory of upgrade. New code s ...
- python之lambda表达式
lambda函数小结 1.lambda表达式: 以前看人家写一个长式子就能干一件我写一个函数干的事情觉得好帅,现在通过学习知道了lambda表达式其原理就是一个函数,而且是一个只能处理简单功能的函数. ...
- How to Type(dp)
How to Type Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...