CF1082E.Increasing Frequency

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given array aa of length nn . You can choose one segment [l,r][l, r] ( 1lrn1 \le l \le r \le n ) and integer value kk (positive, negative or even zero) and change al,al+1,,ara_l, a_{l + 1}, \dots, a_r by kk each (i.e. ai:=ai+ka_i := a_i + k for each lirl \le i \le r ).

What is the maximum possible number of elements with value cc that can be obtained after one such operation?

输入格式

The first line contains two integers nn and cc ( 1n51051 \le n \le 5 \cdot 10^5 , 1c51051 \le c \le 5 \cdot 10^5 ) — the length of array and the value cc to obtain.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 1ai51051 \le a_i \le 5 \cdot 10^5 ) — array aa .

输出格式

Print one integer — the maximum possible number of elements with value cc 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=0k = 0 . The array will stay same.

In the second example we can choose segment [1,3][1, 3] and k=4k = -4 . The array will become [2,2,2][2, -2, 2] .

首页