a127: Blocking Buildings
標籤 : segment tree
通過比率 : 5人/7人 ( 71% ) [非即時]
評分方式:
Tolerant

最近更新 : 2021-10-27 16:46

內容

點下面的連結可以看美美的題目:

https://drive.google.com/file/d/1oHrVfAkhGMLuxNOpZscWNy4HX7ejm4GZ/view?usp=sharing

Capoo owns a street on which $N$ buildings lie in a row. The buildings are numbered $1$ to $n$ from left to right, and the $i$-th one has height $A_i$.

While taller buildings give more profit, they’ve got a major downside: the city’s view may get obstructed by them. Since Capoo likes to take afternoon walks on his street, he does not wish that the buildings are too tall, or they might block the awesome scenery of the city.

Capoo has planned his walks for the next $M$ days. On the $j$-th day, he will start from the $L_j$-th building, walk right to the $R_j$-th one, and admire the sublime views while walking. The “satisfiability” of the walk he will gain on day $j$ is given by the number of buildings between the $L_j$-th and the $R_j$-th one (inclusive) with height not greater than $K_j$.

Given the plans, Capoo wants to know the satisfiability for each day in advance. However, since he is not good at solving these type of problems (he always falls asleep during algorithm classes), he wants you to write a program to help him.

 

翻譯:

給定$1$~$n$每個點的高度,多次詢問某個$[L,R]$區間高度不大於$K$的點有幾個。

輸入說明

The first line consists of two integers $N$ and $M$, the amount of buildings and days Capoo has a plan for. On the second line there are $N$ numbers $ A_1 A_2 ...  A_N $ describing the buildings’ height. Then M lines follow: on the $j$-th line there are three integers $ L_j  R_j  K_j$ describing the walk on day $j$.

• $1≤M, N, A_i , K_i≤2×10^5$

• $1≤L_i≤R_i≤N$

輸出說明

Output $M$ lines, on the $j$-th line print an integer: the satisfiability of the walk on day $j$.

範例輸入 #1
5 3
1 2 3 2 4
1 5 5
1 4 2
2 4 2
範例輸出 #1
5
3
2
測資資訊:
記憶體限制: 512 MB
公開 測資點#0 (9%): 1.0s , <1K
公開 測資點#1 (9%): 1.0s , <1K
公開 測資點#2 (9%): 1.0s , <1M
公開 測資點#3 (9%): 1.0s , <10M
公開 測資點#4 (9%): 1.0s , <10M
公開 測資點#5 (9%): 1.0s , <10M
公開 測資點#6 (9%): 1.0s , <10M
公開 測資點#7 (9%): 1.0s , <10M
公開 測資點#8 (9%): 1.0s , <10M
公開 測資點#9 (9%): 1.0s , <10M
公開 測資點#10 (10%): 1.0s , <10M
提示 :

為什麼Latex編輯右邊會出現一條線!?

如果誰會解決可以教教我QQ

標籤:
segment tree
出處:
NCTU PCCA 2020 [管理者: ]


編號 身分 題目 主題 人氣 發表日期
110
211096@stu.c... (唐狗針)
a127
62 2024-10-19 16:02
33
911091@stu.c... (17莊明達 David)
a127
題解 - 卡常數
234 2023-04-17 08:39