問題一覧 > 通常問題

No.1079 Mao

レベル : / AI推定難易度 : 2025 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 36
作問者 : tko919 / テスター : maspy
お気に入りにしたユーザー ProblemId : 4354 / 自分の提出
問題文最終更新日: 2020-05-22 22:57:52
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 252 (順位表) の他の問題:

Problem Statement

Tako-kun is one of the players of Markov Algorithm Online (commonly known as MAO). He devised an algorithm that performs the following operation: "choose non-negative integers $x,y$, then remove $x$ elements from the left end and $y$ elements from the right end of the sequence."
When Tako-kun applied this algorithm to a sequence $A$ with $N$ elements, he obtained a non-empty sequence $B$ satisfying the following condition.

  • The sum of the two ends of $B$ is $K$, and its minimum value appears exactly $1$ time.
Over all operations possible for the algorithm Tako-kun made, find the sum of the number of elements of $B$. Operations are distinguished only by the chosen non-negative integers $x,y$.

Input

$N\ K$
$A_1\ A_2\ \cdots\ A_N$

All inputs are integers.
$1 \le N \le 10^5$
$0 \le K \le 10^9$
$0 \le A_i \le 10^9 (1 \le i \le N)$

Output

Print the answer to the problem on one line.

Sample

Sample 1
Input
4 4
3 1 2 1
Output
3

The following $2$ operations satisfy the condition.

  • Choose $x=2,y=1$ and obtain $B=\{2\}$.
  • Choose $x=0,y=2$ and obtain $B=\{3,1\}$.
Thus, the sum of the number of elements of $B$ is $1+2=3$.
Choosing $x=y=0$ satisfies the condition on the two ends, but it is invalid because the minimum value $1$ appears $2$ times.
Sample 2
Input
10 8
3 1 4 1 5 9 2 6 5 3
Output
11

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。