시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB0000.000%

문제

This morning, Roxy found $N$ beetles on her desk. These beetles are numbered from $0$ to $N − 1$ and each beetle $i$ has a strength $S_i$. Roxy wants to crush the beetles so she can do her math homework. In order to do this, she bought a special glove which she can use to hit a contiguous subsequence of $K$ beetles. If Roxy makes an effort $E$, then those beetles whose strength $S_i$ is smaller than or equal to $E$ will be crushed, while all others will remain unharmed. The crushed beetles maintain their positions on the desk. Roxy can use the glove as many times as she wants.

Roxy wants to know if you can compute the minimum total effort needed to crush the first $i$ beetles for each $1 ≤ i ≤ N$. Because there are too many numbers, Roxy agreed you should give her the result of the following expression: $X_0 · 23^{N−1} + X_1 · 23^{N−2} + \dots + X_{N−1}$ modulo $10^9 + 7$, where $X_i$ represents the minimum total effort to crush the first $i + 1$ beetles.

구현

The contestant must implement the following function:

int solve(int N, int K, int * S);

This function will be called exactly once and must return the result of the above expression modulo $10^9 + 7$. The parameters of this function are $N$ (the number of beetles), $K$ (the length of the contiguous subsequences she can hit with the glove) and $S$ (an array of length $N$, where $S_i$ represents the strength of beetle $i$).

제한

  • $1 ≤ N ≤ 2\,500\,000$
  • $1 ≤ K ≤ N$
  • $1 ≤ S_i ≤ 2\,000\,000\,000$

서브태스크 1 (18점)

  • $1 ≤ N ≤ 2\,000$

서브태스크 2 (31점)

  • $1 ≤ N ≤ 400\,000$

서브태스크 3 (51점)

  • No additional constraints.

예제 입력 1

8 3
3 2 9 8 7 11 3 4

예제 출력 1

720026253

The array $X$ is $\{3, 3, 9, 12, 12, 20, 23, 23\}$.

첨부

제출할 수 있는 언어

C++17, C++20, C++17 (Clang), C++20 (Clang)

채점 및 기타 정보

  • 예제는 채점하지 않는다.