Raluca and
Ana, which have been good friends ever since childhood, are going to the seaside.
Walking on the shore all day they start collecting seashells. After they've
collected N seashells Ana lines
them up on a string and realizes that they are colored in C
colors. Raluca now wants to choose from the row made up of the N
seashells, a harmonious sequence, as long as possible, in order to make a nice
seashell necklace.
A harmonious sequence is made up of seashells that are consecutive in the row
and that are in all available colors and each has the same appearance frequency
in the sequence.
Seeing as the number of collected seashells can be pretty big (because the girls are very patient), your help is requested.
Task
Help Raluca determine the longest harmonious sequence in the row made up of the N seashells.
Input Data
Input file scoici.in contains on the first line two positive integers separated by a space, N and C where N represents the number of seashells and C the number of colors. On the second line there are N positive integers between 1 and C, each separated by a space, representing the colors of the N seashells in the row.
Output Data
Output file scoici.out will contain a single line, displaying two positive integers separated by a space, poz and lg, where poz represents the position in the row where the harmonious sequence begins and lg represents its length.
Constraints and Statements
scoici.in | scoici.out | Explanation |
9 3 1 2 1 3 3 2 1 1 3 |
1 6 |
The longest sequence is 1 2 1 3 3 2, with frequencies equal to 2 and all 3 colors present. |
Time limit: 0.15 seconds/test
Gheorghe Stefan
ESA, Cybernetics Department
Contact: stefangh@gmail.com