博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ZOJ3741 状压DP Eternal Reality
阅读量:4358 次
发布时间:2019-06-07

本文共 4695 字,大约阅读时间需要 15 分钟。

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

Description

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 21 3 4 5 6 4

Sample Output

4

Hint

Read the problem description carefully.

 

 

 

 

 

#include
#include
using namespace std;int flag1[110]; // 第i关不用技能是否可行int flag2[110]; // 第i关用技能是否可行int flag3[110]; // 第i关是否为0int flag[110][220]; // 表示第i关j状态是否可行int dp[110][220]; // 第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 l, n, x, y; while(scanf("%d %d %d %d",&l, &n, &x, &y) == 4) { memset(flag1, 0, sizeof(flag1)); memset(flag2, 0, sizeof(flag2)); memset(flag3, 0, sizeof(flag3)); memset(flag, 0, sizeof(flag)); memset(dp, 0, sizeof(dp)); int tmp; for(int i = 1; i <= n; i++) { scanf("%d",&tmp); if(l >= tmp) flag1[i] = 1; if(l + 1 >= tmp && l != 5) // 能力值为5,技能+1过关,不可行 { flag2[i] = 1; } if(tmp == 0) flag3[i] = 1; } flag[0][0] = 1; for(int i = 1; i <= n; i++) { for(int j = 0; j <= x + y; j++) { if((j == 0 || j == x + y) && flag[i-1][j]) { //如果前一个状态为 0 或 x+y 并且 前一关状态j可行 //那么下一个状态可以用技能到状态1或不用技能到状态0 dp[i][0] = max(dp[i][0], dp[i-1][j] + flag1[i]);//不用技能 dp[i][1] = max(dp[i][1], dp[i-1][j] + flag2[i]);//用技能 flag[i][0] = flag[i][1] = 1; } else if(j > 0 && j < x + y && flag[i-1][j]) { //当前状态为 >0 &&

 

转载于:https://www.cnblogs.com/13224ACMer/p/4665448.html

你可能感兴趣的文章
Django-中间件实现1分钟内只允许三次访问
查看>>
Python+selenium自动循环送贺卡
查看>>
LeetCode:Decode Ways
查看>>
Tool
查看>>
5.__魔法方法__开会喽
查看>>
Word2013代码高亮插件使用
查看>>
什么是SDN(软件定义网络)(转载)
查看>>
二叉树的广度优先遍历、深度优先遍历的递归和非递归实现方式
查看>>
docker-compose部署kafka
查看>>
IOS中NSUserDefaults的用法(轻量级本地数据存储)
查看>>
cms项目技术心得!
查看>>
Camera Binning Mode
查看>>
Django模板系统
查看>>
位(Bit)与字节(Byte)
查看>>
关于两次指针(struct型)传参数的问题
查看>>
自己制作Linux镜像,CentOS 6.5 Docker自制CentOS镜像
查看>>
linux配置scp交互传输,Linux间传输文件的几种方法scp、sftp
查看>>
linux安装nginx映射目录,centos8自定义目录安装nginx(教程详解)
查看>>
linux cpu scheduler,A Temporal Partition-Based Linux CPU Scheduler
查看>>
c语言怎么写最小公倍数的函数,C语言 · 最小公倍数
查看>>