-
[1455] Malphite
- 时间限制: 1000 ms 内存限制: 65535 K
- 问题描述
-
Granite Shield(花岗岩护盾) - Malphite is shielded by a layer of rock which absorbs damage up to 10% of his maximum Health.
If Malphite has not been hit for 10 seconds, this effect recharges.
To simply this problem all the calculation will in integer not decimal. For example, 15 / 10is 1 not 1.5.
- 输入
-
There are muti-case.
For each case, the first line contain two integer M (0 < m < 10000), N (0 < N < 10000).
M means to the maximum health, N is the time Malphite is attacked.
The following N lines, each line contain two integer Ti ( 0 ≤ Ti ≤ 10000), Di (0 < Di ≤ 100), stands for the attack time and the damage. - 输出
-
For each test case, output the Malphite's final health value, if Malphite can't afford all these damage, print "I'm dead!".
- 样例输入
-
10 2 1 3 4 5 10 2 1 3 11 5 10 1 11 11
- 样例输出
-
3 4 I'm dead!
- 提示
-
无
- 来源
-
Monkeyde17
题目意思是说,熔岩巨兽-墨菲特有一块盾,盾的可以为其抵挡它本身生命值得10%的伤害。如果保持10s不受攻击,那么盾会更新(又可以重新抵挡10%的伤害)。输入第一行是两个整数M和N,分别表示墨菲特的生命值和遭受攻击的次数。接下来N行为每次遭受攻击的时间(单位:秒)和伤害值。要求的是墨菲特最终的生命值,如果墨菲特没能承受所有的攻击,那么直接输出:“I'm dead!”。
作为一个不玩游戏的人,甚至连墨菲特是什么都没听过,更别说这种什么鬼游戏规则了。。。也是问了别人才搞懂题目意思的。。Orz……不玩游戏,怪我咯…~_~…
#include <cstdio> #include <cstring> using namespace std; const int MAXN = 10000 + 50; int n, m, att[MAXN]; bool is[MAXN]; //标记每个单位时间是否受到攻击,用来判断盾是否更新 int main() { while(scanf("%d%d", &m, &n) != EOF) { memset(att, 0, sizeof(att)); memset(is, 0, sizeof(is)); int a, b; for(int i = 0; i < n; i++) { scanf("%d%d", &a, &b); att[a] += b; //这里也可以直接写att[a] = b; 因为同一时间不会重复遭受攻击 is[a]=1; //标记在第 a 秒的时候遭受攻击 } int now = m, pro = now / 10,last = 0; //now为墨菲特的剩余生命值,pro为盾的生命值,last为上一次遭受攻击的时间 for(int i=0; i<=MAXN; i++) { if (i - last >= 10) pro = m / 10; //如果超过10s未受攻击,盾的生命更新 if (is[i]) { //如果第 i 秒遭受攻击 last = i; //更新最后一次被攻击的时间 if (pro) { //如果盾还存在 if (pro >= att[i]) pro -= att[i]; //如果盾的生命值足以抵抗本次攻击,直接抵 else { //否则巨兽的生命值将减掉一部分 now -= (att[i] - pro); pro = 0; //此时,标记盾已损坏 } } else now -= att[i]; //如果盾早已损坏,直接用巨兽生命值抵御攻击 } if (now <= 0) break; //如果生命值已经用完,那么Game over! } if(now>0) printf("%d\n", now); else printf("I'm dead!\n"); } return 0; }