CF526E.Transmitting Levels

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Optimizing the amount of data transmitted via a network is an important and interesting part of developing any network application.

In one secret game developed deep in the ZeptoLab company, the game universe consists of nn levels, located in a circle. You can get from level ii to levels i1i-1 and i+1i+1 , also you can get from level 11 to level nn and vice versa. The map of the ii -th level description size is aia_{i} bytes.

In order to reduce the transmitted traffic, the game gets levels as follows. All the levels on the server are divided into mm groups and each time a player finds himself on one of the levels of a certain group for the first time, the server sends all levels of the group to the game client as a single packet. Thus, when a player travels inside the levels of a single group, the application doesn't need any new information. Due to the technical limitations the packet can contain an arbitrary number of levels but their total size mustn't exceed bb bytes, where bb is some positive integer constant.

Usual situation is that players finish levels one by one, that's why a decision was made to split nn levels into mm groups so that each group was a continuous segment containing multiple neighboring levels (also, the group can have two adjacent levels, nn and 11 ). Specifically, if the descriptions of all levels have the total weight of at most bb bytes, then they can all be united into one group to be sent in a single packet.

Determine, what minimum number of groups do you need to make in order to organize the levels of the game observing the conditions above?

As developing a game is a long process and technology never stagnates, it is yet impossible to predict exactly what value will take constant value bb limiting the packet size when the game is out. That's why the developers ask you to find the answer for multiple values of bb .

输入格式

The first line contains two integers nn , qq ( 2<=n<=1062<=n<=10^{6} , 1<=q<=501<=q<=50 ) — the number of levels in the game universe and the number of distinct values of bb that you need to process.

The second line contains nn integers aia_{i} ( 1<=ai<=1091<=a_{i}<=10^{9} ) — the sizes of the levels in bytes.

The next qq lines contain integers bjb_{j} (), determining the values of constant bb , for which you need to determine the answer.

输出格式

For each value of kjk_{j} from the input print on a single line integer mjm_{j} ( 1<=mj<=n1<=m_{j}<=n ), determining the minimum number of groups to divide game levels into for transmission via network observing the given conditions.

输入输出样例

  • 输入#1

    6 3
    2 4 2 1 3 2
    7
    4
    6
    

    输出#1

    2
    4
    3
    

说明/提示

In the test from the statement you can do in the following manner.

  • at b=7b=7 you can divide into two segments: 2421322|421|32 (note that one of the segments contains the fifth, sixth and first levels);
  • at b=4b=4 you can divide into four segments: 2421322|4|21|3|2 ;
  • at b=6b=6 you can divide into three segments: 24213224|21|32| .
首页