luogu#P3503. [POI2010] KLO-Blocks

[POI2010] KLO-Blocks

题目描述

Bytie has got a set of wooden blocks for his birthday.

The blocks are indistinguishable from one another, as they are all cubes of the same size.

Bytie forms piles by putting one block atop another.

Soon he had a whole rank of such piles, one next to another in a straight line.

Of course, the piles can have different heights.

Bytie's father, Byteasar, gave his son a puzzle.

He gave him a number and asked to rearrange the blocks in such a way that the number of successive piles of height at least is maximised.

However, Bytie is only ever allowed to pick the top block from a pile strictly higher than and place it atop one of the piles next to it.

Further, Bytie is not allowed to form new piles, he can only move blocks between those already existing.

输入格式

In the first line of the standard input there are two integers separated by a single space:

(), denoting the number of piles, and (), denoting the number of Byteasar's requests.

The piles are numbered from to .

In the second line there are integers separated by single spaces ().

The number denotes the height of the -th pile.

The third line holds ![](http://main.edu.pl

输出格式

Your program should print out integers, separated by single spaces, to the standard output - the -th of which should be the answer to the puzzle for the given initial piles set-up and the parameter .

题目大意

给出 nn 个正整数 a1,a2,,ana_1,a_2,\cdots,a_n,再给出一个正整数 kk,现在可以进行如下操作:

  • 每次选择一个大于 kk 的正整数 aia_i,将 aia_i 减去 11 ,选择 ai1a_{i-1}ai+1a_{i+1} 中的一个加上 11

经过一定次数的操作后,问最大能够选出多长的一个连续子序列,使得这个子序列的每个数都不小于 kkmm 组询问。

5 6
1 2 1 1 5
1 2 3 4 5 6
5 5 2 1 1 0

提示

1n1061\le n\le 10^61m501\le m\le 501ai,k1091\le a_i,k\le 10^9