Logo
(追記) (追記ここまで)

23584번 - Dominating Subarray 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB265418.182%

문제

An array $x_1, \ldots, x_\ell$ is a subarray of an array $y_1, \ldots, y_m$ if there exists an integer $i$ from 1ドル$ to $m-\ell+1$ such that the following equalities hold: $y_i = x_1,ドル $y_{i+1} = x_2,ドル $\ldots,ドル $y_{i+\ell-1} = x_{\ell}$.

A subarray $b_1, \ldots, b_k$ of $a$ is $k$-dominating if for any subarray $c_1, \ldots, c_k$ of $a,ドル the following inequalities hold: $b_1 \ge c_1,ドル $b_2 \ge c_2,ドル $\ldots,ドル $b_k \ge c_k$.

You are given an array $a_1, \ldots, a_n$. Find any occurrence of a $k$-dominating subarray of $a$ if it exists.

입력

The first line contains two integers $n$ and $k$ (1ドル \le k \le n \le 100,000円$), the length of the array $a$ and the parameter. The second line contains $n$ integers $a_1, \ldots, a_n$ (1ドル \le a_i \le 10^6$), the elements of the array.

출력

Print "-1" if there is no $k$-dominating subarray in $a$. Otherwise, print an integer $i$ from 1ドル$ to $n-k+1$ such that $a_i, \ldots, a_{i+k-1}$ is a $k$-dominating subarray of $a$.

제한

예제 입력 1

5 3
1 2 3 3 3

예제 출력 1

3

예제 입력 2

3 2
1 2 1

예제 출력 2

-1

힌트

출처

Contest > Open Cup > 2018/2019 Season > Stage 3: Grand Prix of SPb F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /