hdu4970
来源:互联网 发布:java随机昵称生成器 编辑:程序博客网 时间:2024/05/17 00:59
Killing Monsters
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 321 Accepted Submission(s): 190
Problem Description
Kingdom Rush is a popular TD game, in which you should build some towers to protect your kingdom from monsters. And now another wave of monsters is coming and you need again to know whether you can get through it.
The path of monsters is a straight line, and there are N blocks on it (numbered from 1 to N continuously). Before enemies come, you have M towers built. Each tower has an attack range [L, R], meaning that it can attack all enemies in every block i, where L<=i<=R. Once a monster steps into block i, every tower whose attack range include block i will attack the monster once and only once. For example, a tower with attack range [1, 3] will attack a monster three times if the monster is alive, one in block 1, another in block 2 and the last in block 3.
A witch helps your enemies and makes every monster has its own place of appearance (the ith monster appears at block Xi). All monsters go straightly to block N.
Now that you know each monster has HP Hi and each tower has a value of attack Di, one attack will cause Di damage (decrease HP by Di). If the HP of a monster is decreased to 0 or below 0, it will die and disappear.
Your task is to calculate the number of monsters surviving from your towers so as to make a plan B.
The path of monsters is a straight line, and there are N blocks on it (numbered from 1 to N continuously). Before enemies come, you have M towers built. Each tower has an attack range [L, R], meaning that it can attack all enemies in every block i, where L<=i<=R. Once a monster steps into block i, every tower whose attack range include block i will attack the monster once and only once. For example, a tower with attack range [1, 3] will attack a monster three times if the monster is alive, one in block 1, another in block 2 and the last in block 3.
A witch helps your enemies and makes every monster has its own place of appearance (the ith monster appears at block Xi). All monsters go straightly to block N.
Now that you know each monster has HP Hi and each tower has a value of attack Di, one attack will cause Di damage (decrease HP by Di). If the HP of a monster is decreased to 0 or below 0, it will die and disappear.
Your task is to calculate the number of monsters surviving from your towers so as to make a plan B.
Input
The input contains multiple test cases.
The first line of each case is an integer N (0 < N <= 100000), the number of blocks in the path. The second line is an integer M (0 < M <= 100000), the number of towers you have. The next M lines each contain three numbers, Li, Ri, Di (1 <= Li <= Ri <= N, 0 < Di <= 1000), indicating the attack range [L, R] and the value of attack D of the ith tower. The next line is an integer K (0 < K <= 100000), the number of coming monsters. The following K lines each contain two integers Hi and Xi (0 < Hi <= 10^18, 1 <= Xi <= N) indicating the ith monster’s live point and the number of the block where the ith monster appears.
The input is terminated by N = 0.
The first line of each case is an integer N (0 < N <= 100000), the number of blocks in the path. The second line is an integer M (0 < M <= 100000), the number of towers you have. The next M lines each contain three numbers, Li, Ri, Di (1 <= Li <= Ri <= N, 0 < Di <= 1000), indicating the attack range [L, R] and the value of attack D of the ith tower. The next line is an integer K (0 < K <= 100000), the number of coming monsters. The following K lines each contain two integers Hi and Xi (0 < Hi <= 10^18, 1 <= Xi <= N) indicating the ith monster’s live point and the number of the block where the ith monster appears.
The input is terminated by N = 0.
Output
Output one line containing the number of surviving monsters.
Sample Input
521 3 15 5 251 33 15 27 39 10
Sample Output
3HintIn the sample, three monsters with origin HP 5, 7 and 9 will survive.
Source
2014 Multi-University Training Contest 9
Recommend
hujie | We have carefully selected several similar problems for you: 4969 4968 4967 4966 4965
#include <iostream>#include <cstdio>#include <cstring>using namespace std;typedef long long ll;const int Max=100100;ll ans[Max],num[Max];int main(){ int T,t; while(~scanf("%d",&T)&&T){ memset(ans,0,sizeof(ans)); memset(num,0,sizeof(num)); scanf("%d",&t); for(int i=0;i<t;i++){ int bl,br,d; scanf("%d%d%d",&bl,&br,&d); num[bl]+=d; num[br+1]-=d; } for(int i=2;i<Max;i++){ num[i]+=num[i-1]; } ans[100000]=num[100000]; for(int i=99999;i;i--){ ans[i]=ans[i+1]+num[i]; } scanf("%d",&t); int anss=0; for(int i=0;i<t;i++){ long long h,p; scanf("%I64d%d",&h,&p); if(ans[p]<h)anss++; } printf("%d\n",anss); }}
在塔的攻击范围的开头端加攻击力在结束端减攻击力
最后每一项加前面一项来计算每一点的伤害
最后求一下攻击路径上伤害的后缀和就能知道是否能到终点。
0 0
- hdu4970
- hdu4970
- hdu4970 Killing Monsters
- HDU4970-Killing Monsters
- HDU4970:Killing Monsters
- HDU4970 Killing Monsters
- hdu4970-Killing Monsters
- Killing Monsters(hdu4970)
- HDU4970 Killing Monsters 【数组标记】
- hdu4970(后缀和,标记法的区间更新)
- hdu4970 Killing Monsters(模拟塔防游戏)
- Killing Monsters(不使用线段树)HDU4970
- 省赛训练题(HDU4968,HDU4970,HDU4864)
- HDU4970 Killing Monsters (2014多校第九场第11题)
- 淘宝数据库OceanBase SQL编译器部分 源码阅读--生成逻辑计划
- Navi PushVC及Present VC的屏幕旋转
- 浏览器最核心的部分是渲染引擎
- poj 3077 Rounders 【简单字符串处理】
- Arch Linux下VMware-Tools安装笔记
- hdu4970
- Queue
- 正则表达式的使用(2)__常用的正则表达式(积累)
- 面试中strcpy源码的判分标准
- 淘宝数据库OceanBase SQL编译器部分 源码阅读--生成物理查询计划
- 天津出差系列(四)----第四天
- 淘宝数据库OceanBase SQL编译器部分 源码阅读--Schema模式
- poj 1546 进制转换
- Linux系统编程之访问文件夹及其文件属性