#P9991. [Ynoi Easy Round 2023] TEST_107
[Ynoi Easy Round 2023] TEST_107
Problem Description
Given a sequence of length with indices from to , there are queries. Each query gives an interval . You need to find a sub-interval satisfying , such that the number of distinct values that appear in is less than the number of distinct values that appear in , and its length is as large as possible. If no such sub-interval exists, output .
Input Format
The first line contains two integers .
The next line contains integers, which are the elements of the sequence .
Then follow lines, each containing two integers representing a query. You only need to output the length of the sub-interval, i.e. .
Output Format
For each query, output one integer per line representing the answer.
5 4
1 3 2 3 4
2 4
1 3
2 5
1 1
1
2
3
0
Hint
Idea: ccz181078, Solution: ccz181078, Code: ccz181078, Data: ccz181078.
Constraints:
For of the testdata, .
For of the testdata, .
For another of the testdata, .
For of the testdata, .
Translated by ChatGPT 5