Codeforces Round #699 (Div. 2) B. New Colony

本文介绍了Codeforces编程竞赛中的一道题目——B. New Colony,涉及将山脉用石块平移以建立新殖民地的模拟过程。内容包括输入输出格式、示例测试用例及其解析,以及问题解决策略。
摘要由CSDN通过智能技术生成

B. New Colony

time limit per test:2 seconds
memory limit per test:256 megabytes
input:standard input
output:standard output

After reaching your destination, you want to build a new colony on the new planet. Since this planet has many mountains and the colony must be built on a flat surface you decided to flatten the mountains using boulders (you are still dreaming so this makes sense to you).


You are given an array h1,h2,…,hn, where hi is the height of the i-th mountain, and k — the number of boulders you have.

You will start throwing boulders from the top of the first mountain one by one and they will roll as follows (let’s assume that the height of the current mountain is hi):

if hi≥hi+1, the boulder will roll to the next mountain;
if hi<hi+1, the boulder will stop rolling and increase the mountain height by 1 (hi=hi+1);
if the boulder reaches the last mountain it will fall to the waste collection system and disappear.
You want to find the position of the k-th boulder or determine that it will fall into the waste collection system.

Input

The first line contains a single integer t (1≤t≤100) — the number of
test cases.

Each test case consists of two lines. The first line in each test case
contains two integers n and k (1≤n≤100; 1≤k≤109) — the number of
mountains and the number of boulders.

The second line contains n integers h1,h2,…,hn (1≤hi≤100) — the height
of the mountains.

It is guaranteed that the sum of n over all test cases does not exceed
100.

Output

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值