e-eternal RealityTime
limit:2000MS
Memory Limit:65536KB
64bit IO Format:%lld &%llu Submit Status Practice ZOJ 3741
Description
In the AcademyCity, the most students has special abilities. Such as railgun, teleport, telekinesis, AIM stalker and so on. Here, AIM (an involuntary movement) are a term used to refer to the phenomenon in which an esper involuntarily produces an Invisible energy field around the Esper. Different students has Different type of AIM dispersion field, so they also has 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 AcademyCity, there is 7 levels in total:
| Level
| Term
Description |
Level 0 |
Person with No Powers |
Most students of the The 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 is not very useful in everyday life. |
Level 3 |
Person with strong Powers |
The degree when powers was considered convenient in everyday life, ability-wise this was the level when one starts to be TR Eated 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, 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 and the help's level Upper (it have no effect on persons with super Powers). Since this, many institutions has been doing long-term researches about it, such as the Radio Noise Project. |
You is a student of level in Academy city and you is going to take part in L a sports competition. The competition consists of N consecutive matches. If you want to get a point i in the-th match, your must reach at least level Ai . According to the rules, you must compete in all matches one by one.
To tell the truth, it won ' t is easy-to-compete with so many high-level opponents. Fortunately, 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 i the-th match, it's effect'll last during the matches [i, i + X - 1] . But it also have a side effect that would make your level become 0 during the matches [i + X, i + X + Y - 1] . After the side effect ends, your level would return to and you can use the level L Upper again.
Please calculate the maximal points your can get if you properly with the level Upper.
Input
There is 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 & lt;= 100). The next line contains N integers Ai (0 <= Ai <= 6).
Output
For each test case, the output of 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 <stdio.h>#include<string.h>using namespacestd;intflag1[ the];//I close the use of skills is feasibleintflag2[ the];//The feasibility of using the first skillintflag3[ the];//whether or not the first I-Close is 0intflag[ the][ -];//indicates whether the status of J is feasibleintdp[ the][ -];//The maximum clearance number of the status of J for the I-off//here the state range is [0, X+y], divided into three categories//[0] normal state, [1,x] using skill +1 state, [x+1,x+y] skill recovery in ability value is 0 StateintMaxintAintb) { returna > B?a:b;}intMain () {intl, 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)); inttmp; for(inti =1; I <= N; i++) {scanf ("%d",&tmp); if(l >= tmp) flag1[i] =1; if(L +1>= tmp && L! =5)//Ability value is 5, skill +1 Pass, not OK{Flag2[i]=1; } if(TMP = =0) Flag3[i] =1; } flag[0][0] =1; for(inti =1; I <= N; i++) { for(intj =0; J <= x + y; J + +) { if(J = =0|| j = = x + y) && flag[i-1][j]) {//If the previous state is 0 or x+y and the previous state J is feasible//then the next state can use the skill to state 1 or no skill to state 0dp[i][0] = max (dp[i][0], dp[i-1][J] + flag1[i]);//No Skillsdp[i][1] = max (dp[i][1], dp[i-1][J] + flag2[i]);//with Skillsflag[i][0] = flag[i][1] =1; } Else if(J >0&& J < x + y && flag[i-1][j]) {//current status is >0 && <x+y description already used skills//then the next state can only be in the range of [2, X+y]//then the previous state J can be divided into [1,x] and [X, x+y) consider if(J <x) {dp[i][j+1] = max (dp[i][j+1], dp[i-1][J] + flag2[i]);//skills must be used } Else{dp[i][j+1] = max (dp[i][j+1], dp[i-1][J] + flag3[i]);//skill cooldown, capability value is 0} flag[i][j+1] =1; } } } intAns =0; for(inti =0; I <= x + y; i++) {ans=Max (ans, dp[n][i]); } printf ("%d\n", ans); } return 0;}
ZOJ3741 pressure DP Eternal Reality