编程介的小学生 2017-12-01 09:49 采纳率: 20.5%
浏览 854
已采纳

Skyscrapers

Problem Description
In a seaside village, there is an avenue of skyscrapers. Each skyscrapers is 100m 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 suficient 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 5 skyscrapers after 2 days is given below.

Input
The input contains several test cases. The first line contains an integer t (t <= 15) denoting the number of test cases. Then t test cases follow. Each of them begins with a line containing two numbers n and d (1 <= n, d <=10^6), n is the number of skyscrapers and d is the number of days which the major wants
to query.

Skyscrapers are numbered from left to right. The next line contains n integers h1,h2,..., hn where 1 <= hi <= 10^9 is the height of skyscraper i. The third line of a single test case contains d numbers tj such that 0 <= t1 < t2 < ... < td-1 < td <=10^9.

Output
For each test case output d numbers r1,r2,...,rd, where rj is the number of regions on day tj .

Sample Input
2
3 3
1 2 3
1 2 3
5 3
1 3 5 1 3
0 2 4

Sample Output
1 1 0
1 2 1

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题