WaveTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 702 Accepted Submission(s): 209
Problem Description Avin is studying series. A series is called "wave" if the following conditions are satisfied: 1) It contains at least two elements; 2) All elements at odd positions are the same; 3) All elements at even positions are the same; 4) Elements at odd positions are NOT the same as the elements at even positions. You are given a series with length n. Avin asks you to find the longest "wave" subseries. A subseries is a subsequence of a series.
Input The first line contains two numbers n, c (1 ¡Ü n ¡Ü 100, 000, 1 ¡Ü c ¡Ü 100). The second line contains n integers whose range is [1, c], which represents the series. It is guaranteed that there is always a "wave" subseries.
Output Print the length of the longest "wave" subseries.
Sample Input
Sample Output Statistic | Submit | Clarifications | Back
|