[Solution] Rising Sand Codeforces Solution | Codeforces Problem Solution 2022
There are piles of sand where the -th pile has blocks of sand. The -th pile pile is called too tall if and . That is, a pile is too tall if it has more sand than its two neighbours combined. (Note that piles on the ends of the array cannot be too tall.)
You are given an integer . An operation consists of picking consecutive piles of sand and adding one unit of sand to them all. Formally, pick such that . Then for all , update .
What is the maximum number of piles that can simultaneously be too tall after some (possibly zero) operations?
The input consists of multiple test cases. The first line contains an integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers and (; ) — the number of piles of sand and the size of the operation, respectively.
The second line of each test case contains integers () — the sizes of the piles.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, output a single integer — the maximum number of piles that are simultaneously too tall after some (possibly zero) operations.
No comments:
Post a Comment