#P10169. [DTCPC 2024] mex,min,max
[DTCPC 2024] mex,min,max
Problem Description
Given a sequence and , find how many subarrays satisfy $\operatorname{mex}\{a_l,a_{l+1},\dots,a_{r-1},a_r\}+\min\{a_l,a_{l+1},\dots,a_{r-1},a_r\}+k\geq \max\{a_l,a_{l+1},\dots,a_{r-1},a_r\}$.
is defined as the smallest non-negative integer that does not appear in the set.
Input Format
The first line contains two integers ().
The second line contains non-negative integers, where the -th one is ().
Output Format
One line with one number, representing the number of subarrays that satisfy the condition.
3 0
1 0 2
5
Hint
Translated by ChatGPT 5