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

21095번 - Best Subsequence 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 1024 MB89221418.667%

문제

We call $W$ a $k$-best number of sequence $B_{1...m}$ if there exists a sequence $C_{1...k}$ satisfying the following two conditions:

  1. $C_{1...k}$ is a subsequence of $B_{1...m}$.
  2. $\forall i \in [1, k], C_{i} + C_{(i \bmod k) + 1} \le W$.

Given a sequence $A_{1...n},ドル you need to answer $Q$ questions. Each question consists of three integers $L, R, K,ドル and you need to calculate the minimum $K$-best number of $A_{L...R}$.

Recall that $C$ is a subsequence of $B$ if and only if we can obtain $C$ by removing some elements of $B$ (possibly none or all).

입력

The first line contains two integers $n$ and $Q$ (1ドル \le n, Q \le 10^5$).

The second line contains $n$ integers $A_{1...n}$ (0ドル \le A_i \le 10^9$).

Then $Q$ lines follow. Each of them contains three integers $L, R, K,ドル representing a question (1ドル \le L \le R \le n$; 1ドル \le K \le R - L + 1$).

출력

For each question, output a single line with a single integer: the answer.

제한

예제 입력 1

5 3
2 6 1 5 4
1 5 4
1 3 2
1 5 3

예제 출력 1

8
3
6

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2021 > Day 6: PKU Contest 2 A번

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

출처

대학교 대회

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

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