设为首页 加入收藏

TOP

求区间内小于num的数的个数(一)
2012-11-17 09:26:51 来源: 作者: 【 】 浏览:1037
Tags:区间 小于 num 个数

    Super Mario

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

    Total Submission(s): 771    Accepted Submission(s): 423

    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

    Source

    2012 ACM/ICPC Asia Regional Hangzhou Online

   

首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C++程序当中异常安全的思考 下一篇算法导论-二叉排序树

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: