uzastopni
You are given an array of integers. You have to find the shortest substring that contains only the elements from the interval [ A, B ]. Also, every integer from the interval [ A, B ] has to appear at least once in the substring. If there is no such substring output -1.
InputThe first line contains three integers n, A and B (1 <= n <= 1.000.000, 1 <= A <= B <= 1.000.000.000). The following line contains n integers from the interval [1, 1.000.000.000] representing the array.
OutputOutput the length of such shortest substring, or -1 if there is none.
Input:
Output:
Explanation:
The shortest substring exists, its length is 5. It starts from the 7th element of the array.
22 5 7
5 7 8 6 1 1000 6 7 7 7 5 5 5 5 7 7 7 7 7 6 6 6Output:
5Explanation:
The shortest substring exists, its length is 5. It starts from the 7th element of the array.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.