No.1079 Mao
問題文最終更新日: 2020-05-22 22:57:52
English (AI translation)
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.
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\}$.
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もしくは右上の雲マークをクリックしてアカウントを作成してください。
tko919
maspy