CF1481B.New Colony

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

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,,hnh_1, h_2, \dots, h_n , where hih_i is the height of the ii -th mountain, and kk — 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 hih_i ):

  • if hihi+1h_i \ge h_{i + 1} , the boulder will roll to the next mountain;
  • if hi<hi+1h_i < h_{i + 1} , the boulder will stop rolling and increase the mountain height by 11 ( hi=hi+1h_i = h_i + 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 kk -th boulder or determine that it will fall into the waste collection system.

输入格式

The first line contains a single integer tt ( 1t1001 \le t \le 100 ) — the number of test cases.

Each test case consists of two lines. The first line in each test case contains two integers nn and kk ( 1n1001 \le n \le 100 ; 1k1091 \le k \le 10^9 ) — the number of mountains and the number of boulders.

The second line contains nn integers h1,h2,,hnh_1, h_2, \dots, h_n ( 1hi1001 \le h_i \le 100 ) — the height of the mountains.

It is guaranteed that the sum of nn over all test cases does not exceed 100100 .

输出格式

For each test case, print 1-1 if the kk -th boulder will fall into the collection system. Otherwise, print the position of the kk -th boulder.

输入输出样例

  • 输入#1

    4
    4 3
    4 1 2 3
    2 7
    1 8
    4 5
    4 1 2 3
    3 1
    5 3 1

    输出#1

    2
    1
    -1
    -1

说明/提示

Let's simulate the first case:

  • The first boulder starts at i=1i = 1 ; since h1h2h_1 \ge h_2 it rolls to i=2i = 2 and stops there because h2<h3h_2 < h_3 .
  • The new heights are [4,2,2,3][4,2,2,3] .
  • The second boulder starts at i=1i = 1 ; since h1h2h_1 \ge h_2 the boulder rolls to i=2i = 2 ; since h2h3h_2 \ge h_3 the boulder rolls to i=3i = 3 and stops there because h3<h4h_3 < h_4 .
  • The new heights are [4,2,3,3][4,2,3,3] .
  • The third boulder starts at i=1i = 1 ; since h1h2h_1 \ge h_2 it rolls to i=2i = 2 and stops there because h2<h3h_2 < h_3 .
  • The new heights are [4,3,3,3][4,3,3,3] .

The positions where each boulder stopped are the following: [2,3,2][2,3,2] .

In the second case, all 77 boulders will stop right at the first mountain rising its height from 11 to 88 .

The third case is similar to the first one but now you'll throw 55 boulders. The first three will roll in the same way as in the first test case. After that, mountain heights will be equal to [4,3,3,3][4, 3, 3, 3] , that's why the other two boulders will fall into the collection system.

In the fourth case, the first and only boulders will fall straight into the collection system.

首页