303167: CF616D. Longest k-Good Segment

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Longest k-Good Segment

题意翻译

给定一个包含$n$个整数的序列$a$,$0\le a_i \le 10^6$ ,询问不重复数字个数$\le k$的最长区间的左右端点。如果有多解输出任意一组。

题目描述

The array $ a $ with $ n $ integers is given. Let's call the sequence of one or more consecutive elements in $ a $ segment. Also let's call the segment k-good if it contains no more than $ k $ different values. Find any longest k-good segment. As the input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use scanf/printf instead of cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.

输入输出格式

输入格式


The first line contains two integers $ n,k $ ( $ 1<=k<=n<=5·10^{5} $ ) — the number of elements in $ a $ and the parameter $ k $ . The second line contains $ n $ integers $ a_{i} $ ( $ 0<=a_{i}<=10^{6} $ ) — the elements of the array $ a $ .

输出格式


Print two integers $ l,r $ ( $ 1<=l<=r<=n $ ) — the index of the left and the index of the right ends of some k-good longest segment. If there are several longest segments you can print any of them. The elements in $ a $ are numbered from $ 1 $ to $ n $ from left to right.

输入输出样例

输入样例 #1

5 5
1 2 3 4 5

输出样例 #1

1 5

输入样例 #2

9 3
6 5 1 2 3 2 1 4 5

输出样例 #2

3 7

输入样例 #3

3 1
1 2 3

输出样例 #3

1 1

Input

题意翻译

给定一个包含$n$个整数的序列$a$,$0\le a_i \le 10^6$ ,询问不重复数字个数$\le k$的最长区间的左右端点。如果有多解输出任意一组。

加入题单

上一题 下一题 算法标签: