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",& ...
随机推荐
- OC中对象拷贝概念
OC中的对象拷贝概念,这个对于面向对象语言中都会有这种的问题,只是不同的语言有不同的解决方式:C++中有拷贝构造函数,Java中需要实现Cloneable接口,在clone方法中进行操作.但是不过OC ...
- scanf 和cin 的区别
笔试的时候经常遇到突然string s;cin>>s; 有的时候编译会错误,不知道为什么. 今天在练习枚举类型的时候,也遇到这样一个问题. enum weekday{Monday,Tues ...
- 在MyEclipse环境下添加MySql数据库
首先最好在添加的时候,确保你的数据库处于打开状态:其次,要按照jdbc:mysql://[host:port],[host:port].../[database]把url写对:然后,需要添加mysql ...
- WIN7/8系统下程序接收不到WM_COPYDATA 消息的原因和解决
在WIN7/win8,如果发送消息的程序用户权限低于和接收消息的程序,则消 息无法传递.发送程序必须等于或者等于接收程序的权限.如发送与接收 是同一个用户,或者发送是管理员帐户,接收是是普通用户,这样 ...
- 转 ——eclipse下进行Python开发 环境配置
python for eclipse插件安装1.下载python for eclipsepython for eclipse下载地址,如:org.python.pydev.feature-1.6.3. ...
- OSG报警特效学习总结
方法一:粒子系统 OSG的粒子系统有自己定义好的模块,如osgParticle::ExplosionEffect(爆炸模拟):osgParticle::SmokeEffect(烟雾模拟 ...
- cdoj 847 方老师与栈 火车进出战问题
//其实我是不想写这题的,但是这题让我想起了我年轻的时候 解法:直接模拟栈就好. //另外我年轻时候做的那题数据范围比较小,原理也不一样. //对于序列中的任何一个数其后面所有比它小的数应该是倒序的, ...
- nodejs项目中的路由写法
//两种路由写法,一种封装成函数,返回结果,此种方法可以传递参数, "use strict"; var _ = require("lodash"); var e ...
- android上下文
在android中常常会遇到与context有关的内容 浅论一下context : 在语句 AlertDialog.Builder builder = new AlertDialog.Builder( ...
- S3C2416裸机开发系列十六_sd卡驱动实现
S3C2416裸机开发系列十六 sd卡驱动实现 象棋小子 1048272975 SD卡(Secure Digital Memory Card)具有体积小.容量大.传输数据快.可插拔.安全性好等长 ...