问题2277--超级马里奥(HDU4417)

2277: 超级马里奥(HDU4417)

时间限制: 1 Sec  内存限制: 128 MB
提交: 0  解决: 0
[提交] [状态] [讨论版] [命题人:]

题目描述

Mario is world-famous plumber. His “burly” figure and amazing jumping ability reminded in our memory. Now the poor princess is in trouble again and Mario needs to save his lover. We regard the road to the boss’s castle as a line (the length is n), on every integer point i there is a brick on height hi. Now the question is how many bricks in [L, R] Mario can hit if the maximal height he can jump is H.

大意:
可怜的公主陷入困境,马里奥需要拯救他的情人。把通往城堡的道路视为一条线(长度为n),在每个整数点i上都有一块高度为hi 的砖,马里奥可以跳的最大高度是H,求他在[L,R]区间可以跳过多少砖块。

输入

The first line follows an integer T, the number of test data.
For each test data:
The first line contains two integers n, m (1 <= n <=10^5, 1 <= m <= 10^5), n is the length of the road, m is the number of queries.
Next line contains n integers, the height of each brick, the range is [0, 1000000000].
Next m lines, each line contains three integers L, R,H.( 0 <= L <= R < n 0 <= H <= 1000000000.)
大意:

第1行是整数T,表示测试用例的数量。每个测试用例的第1行都包含两个整数n、m(1≤n,m≤105),n是道路的长度,m是查询的数量。下一行包含n个整数,表示每个砖的高度(范围是[0,109])。接下来的m 行,每行都包含三个整数L、R、H (0≤LR<n,0≤H109)。

输出

对每种情况都输出“Case X: ”(X是从1开始的案例编号),后跟m行,每行都包含一个整数。第i个整数是第i个查询中马里奥跳过的砖块数。

样例输入 Copy

1
10 10
0 5 2 7 5 4 3 8 7 7 
2 8 6
3 5 0
1 3 1
1 9 4
0 1 0
3 5 5
5 5 1
4 6 3
1 5 7
5 7 3

样例输出 Copy

Case 1:
4
0
0
3
1
2
0
1
5
1

来源/分类