CF1082E.Increasing Frequency
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given array a of length n . You can choose one segment [l,r] ( 1≤l≤r≤n ) and integer value k (positive, negative or even zero) and change al,al+1,…,ar by k each (i.e. ai:=ai+k for each l≤i≤r ).
What is the maximum possible number of elements with value c that can be obtained after one such operation?
输入格式
The first line contains two integers n and c ( 1≤n≤5⋅105 , 1≤c≤5⋅105 ) — the length of array and the value c to obtain.
The second line contains n integers a1,a2,…,an ( 1≤ai≤5⋅105 ) — array a .
输出格式
Print one integer — the maximum possible number of elements with value c which can be obtained after performing operation described above.
输入输出样例
输入#1
6 9 9 9 9 9 9 9
输出#1
6
输入#2
3 2 6 2 6
输出#2
2
说明/提示
In the first example we can choose any segment and k=0 . The array will stay same.
In the second example we can choose segment [1,3] and k=−4 . The array will become [2,−2,2] .