Sicily 13295. Kingdom Rush I

来源:互联网 发布:中文翻译缅甸语软件 编辑:程序博客网 时间:2024/05/19 05:06

13295. Kingdom Rush I

Constraints

Time Limit: 1 secs, Memory Limit: 256 MB

Description

Kingdom Rush is a popular TD game, in which you should build some towers to protect your kingdom from monsters. And now a new wave of monsters is coming and you need to know whether you can get through it.

 

To simplify this problem, 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. Besides, each monster comes from block 1 and go straightly to block N. 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.

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, 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 first line of the input is a number N, the number of blocks in the path. (0 < N <= 10^9)

The second line is a number M, the number of towers you have. (0 < M <= 10000)

The next M line, the ith (1 <= i <= M) line contains three numbers, Li , Ri, Di, the attack range [L,R] and the value of attack D of the ith tower. (1 <= Li <= Ri <= N, 0 < Di <= 1000)

The next line is a number K, the number of coming monsters. (0 < K <= 10000)

The last line contains K numbers Hi, live point of each monster. (0 < Hi <= 10^18)

Output

Output one line containing the number of surviving monsters.

Sample Input

521 3 15 5 251 3 5 7 9

Sample Output

2

Hint

In the sample, two monsters with origin HP 7 and 9 will survive.

Problem Source

"6CIT杯"第五届中山大学ICPC新手赛 by 莫益阶

// Problem#: 13295// Submission#: 3560624// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/// All Copyright reserved by Informatic Lab of Sun Yat-sen University#include <stdio.h>int main() {    long long N, M, sum = 0, st, ed, da, K, H, ans = 0;    scanf("%lld%lld", &N, &M);    while (M--) {        scanf("%lld%lld%lld", &st, &ed, &da);        sum += (ed - st + 1) * da;    }    scanf("%lld", &K);    while (K--) {        scanf("%lld", &H);        if (H > sum) ans++;    }    printf("%lld\n", ans);    return 0;}                                 


0 0
原创粉丝点击