eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Skyscrapers

Skyscrapers

In a seaside village, there is an avenue of skyscrapers. Each skyscrapers is \textbf{100}m wide and has certain height. Due to very high price of parcels, any two consecutive skyscrapers are adjacent. The avenue lies close to the beach so the street is exactly at the sea level. Unfortunately, this year, due to the global warming, the sea level started to increase by one meter each day. If the skyscraper height is no greater than the current sea level, it is considered flooded. A region is a maximal set of non-flooded, adjacent skyscrapers. This term is of particular importance, as it is sufficient to deliver goods (like current, carrots or cabbages) to any single skyscraper in each region. Hence, the city major wants to know how many regions there will be in the hard days that come. An example of an avenue with \textbf{5} skyscrapers after \textbf{2} days is given below. \includegraphics{https://static.e-olymp.com/content/66/660169ae052b63a1f31013ee3f7ab74cf7d0363b.jpg} \InputFile The input contains several test cases. The first line contains an integer \textbf{t }(\textbf{t }≤ \textbf{15}) denoting the number of test cases. Then \textbf{t }test cases follow. Each of them begins with a line containing two numbers \textbf{n }and \textbf{d }(\textbf{1 }≤ \textbf{n}, \textbf{d }≤ \textbf{10^6}), \textbf{n} is the number of skyscrapers and \textbf{d }is the number of days which the major wants to query. Skyscrapers are numbered from left to right. The next line contains \textbf{n }integers \textbf{h_1}, \textbf{h_2}, ..., \textbf{h_n} where \textbf{1 }≤ \textbf{h_\{i \}}≤ \textbf{10^9} is the height of skyscraper \textbf{i}. The third line of a single test case contains \textbf{d }numbers \textbf{t_j} such that \textbf{0 }≤ \textbf{t_1} < \textbf{t_2} < ... < \textbf{t_\{d-1\}} < \textbf{t_\{d \}}≤ \textbf{10^9}. \OutputFile For each test case output \textbf{d }numbers \textbf{r_1}, \textbf{r_2}, ..., \textbf{r_d}, where \textbf{r_j} is the number of regions on day \textbf{t_j}.
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
2
3 3
1 2 3
1 2 3
5 3
1 3 5 1 3
0 2 4
Выходные данные #1
1 1 0
1 2 1
Источник 2008 ACM CERC, Польша, Вроцлав, Ноябрь 28-30, Задача B