The sum is not without variety
Very easy
Execution time limit is 2 seconds
Runtime memory usage limit is 256 megabytes
Given a sequence of integers (A_1, A_2, ..., A_N).
Your task is to find a subsequence of consecutive numbers, (A_i, A_i+1, ..., A_j), that contains at least (K) distinct numbers. Additionally, you need to maximize the sum (S = A_i + A_i+1 + ...+ A_j).
Input
The first line of input provides the integers (N) and (K) ((1 K N 200,000)).
The second line contains (N) integers (A_1, A_2, ..., A_N) where (|A_i| 1,000,000,000).
Output
On the first line, output the maximum possible value of the sum (S). On the second line, output the indices of the first and last elements of the optimal subsequence found. If there are multiple solutions, any valid one will suffice.
If no subsequence meets the criteria, output a single line with the word "IMPOSSIBLE".
Examples
Input #1
Answer #1
Submissions 156
Acceptance rate 19%