CF1676F.Longest Strike

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Given an array aa of length nn and an integer kk , you are tasked to find any two numbers ll and rr ( lrl \leq r ) such that:

  • For each xx (lxr)(l \leq x \leq r) , xx appears in aa at least kk times (i.e. kk or more array elements are equal to xx ).
  • The value rlr-l is maximized.

If no numbers satisfy the conditions, output -1.

For example, if a=[11,11,12,13,13,14,14]a=[11, 11, 12, 13, 13, 14, 14] and k=2k=2 , then:

  • for l=12l=12 , r=14r=14 the first condition fails because 1212 does not appear at least k=2k=2 times.
  • for l=13l=13 , r=14r=14 the first condition holds, because 1313 occurs at least k=2k=2 times in aa and 1414 occurs at least k=2k=2 times in aa .
  • for l=11l=11 , r=11r=11 the first condition holds, because 1111 occurs at least k=2k=2 times in aa .

A pair of ll and rr for which the first condition holds and rlr-l is maximal is l=13l = 13 , r=14r = 14 .

输入格式

The first line of the input contains a single integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases. The description of test cases follows.

The first line of each test case contains the integers nn and kk ( 1n21051 \le n \le 2 \cdot 10^5 , 1kn1 \leq k \leq n ) — the length of the array aa and the minimum amount of times each number in the range [l,r][l, r] should appear respectively.

Then a single line follows, containing nn integers describing the array aa ( 1ai1091 \leq a_i \leq 10^9 ).

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5 .

输出格式

For each test case output 22 numbers, ll and rr that satisfy the conditions, or "-1" if no numbers satisfy the conditions.

If multiple answers exist, you can output any.

输入输出样例

  • 输入#1

    4
    7 2
    11 11 12 13 13 14 14
    5 1
    6 3 5 2 1
    6 4
    4 3 4 3 3 4
    14 2
    1 1 2 2 2 3 3 3 3 4 4 4 4 4

    输出#1

    13 14
    1 3
    -1
    1 4
首页