博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[HDU 4417]Super Mario
阅读量:6293 次
发布时间:2019-06-22

本文共 1849 字,大约阅读时间需要 6 分钟。

Problem Description

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.

Input

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.)

Output

For each case, output "Case X: " (X is the case number starting from 1) followed by m lines, each line contains an integer. The ith integer is the number of bricks Mario can hit for the ith query.

Sample Input

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

Sample Output

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

题解:

主席树模板题...

1 //Never forget why you start 2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #define ll(x) seg[x].l 9 #define rr(x) seg[x].r10 using namespace std;11 int n,m,t,b[100005],mmax;12 struct node{13 int x,pos,cnt;14 friend bool operator < (const node a,const node b){15 return a.x
>1;37 if(x<=mid)insert(ll(root),l,mid,x);38 if(mid
b[right]||r
>1,ans=0;46 if(l<=b[mid])ans+=query(ll(lroot),ll(rroot),left,mid,l,r);47 if(b[mid]

 

转载于:https://www.cnblogs.com/huangdalaofighting/p/8277764.html

你可能感兴趣的文章
Mysql-5.6.x多实例配置
查看>>
psutil
查看>>
在git@osc上托管自己的代码
查看>>
机器学习算法:朴素贝叶斯
查看>>
小五思科技术学习笔记之扩展访问列表
查看>>
使用Python脚本检验文件系统数据完整性
查看>>
使用MDT部署Windows Server 2003 R2
查看>>
Redhat as5安装Mysql5.0.28
查看>>
通过TMG发布ActiveSync
查看>>
Web服务器的配置与管理(4) 配置访问权限和安全
查看>>
ClientScriptManager与ScriptManager向客户端注册脚本的区别
查看>>
js和php中几种生成验证码的方式
查看>>
android UI进阶之仿iphone的tab效果1
查看>>
这是我的第1个C#程序(向控制台输出一句话)
查看>>
html
查看>>
Xqk.Data数据框架开发指南:丰富的、灵活的查询方法(第三部分:SqlField)
查看>>
工作第十五周:上线前的惊悚
查看>>
Java获取EXE文件图标的方法
查看>>
深入解析Django Admin模块
查看>>
SQL Server死锁详解
查看>>