CF558B.Amr and The Large Array

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller.

Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number occurs in this array. He wants to choose the smallest subsegment of this array such that the beauty of it will be the same as the original array.

Help Amr by choosing the smallest subsegment possible.

Amr 得到了一个大小为 nn 的大数组。Amr 不喜欢大数组,因此他打算将它变小。

Amr 对数组中的其他一切都不关心,只关心它的“美感”。数组的“美感”定义为该数组中某个数字出现次数的最大值。他希望选出原数组的一个最短子段(连续子数组),使得该子段的“美感”与原数组相同。

请帮助 Amr 选出可能的最短子段。

输入格式

The first line contains one number n (1 ≤ n ≤ 105), the size of the array.

The second line contains n integers a__i (1 ≤ a__i ≤ 106), representing elements of the array.

第一行包含一个整数 nn(1≤n≤1051 \leq n \leq 10^5),表示数组的大小。

第二行包含 nn 个整数 aia_i(1≤ai≤1061 \leq a_i \leq 10^6),表示数组的元素。

输出格式

Output two integers l, r (1 ≤ l ≤ r ≤ n), the beginning and the end of the subsegment chosen respectively.

If there are several possible answers you may output any of them.

输出两个整数 ll 和 rr(1 ≤ l ≤ r ≤ n1 ≤ l ≤ r ≤ n),分别表示所选子区间的起始位置和结束位置。

如果存在多个可能的答案,你可以输出其中任意一个。

输入输出样例

  • 输入#1

    5
    1 1 2 2 1

    输出#1

    1 5
  • 输入#2

    5
    1 2 2 3 1

    输出#2

    2 3
  • 输入#3

    6
    1 2 2 1 1 2

    输出#3

    1 5

说明/提示

A subsegment B of an array A from l to r is an array of size r - l + 1 where B__i = A__l + i - 1 for all 1 ≤ i ≤ r - l + 1

数组 AA 从 ll 到 rr 的一个子段 BB 是一个长度为 r−l+1r - l + 1 的数组,其中对所有 1≤i≤r−l+11 \leq i \leq r - l + 1,均有 Bi=Al+i−1B_i = A_{l + i - 1}。

输入解题思路,AI测评打分。不知道怎么写?

首页