CF1082E.Increasing Frequency
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
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?
给你一个长度为 n 的数组 a。你可以选择一个区间 [l,r](其中 1≤l≤r≤n)和一个整数 k(可以为正数、负数,甚至零),并将 al,al+1,…,ar 中的每个元素都增加 k(即对每个满足 l≤i≤r 的 i,执行 ai:=ai+k)。
在执行一次这样的操作后,最多能得到多少个值为 c 的元素?
输入格式
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.
第一行包含两个整数 n 和 c(1≤n≤5⋅105,1≤c≤5⋅105)—— 分别表示数组的长度以及需要得到的值 c。
第二行包含 n 个整数 a1,a2,…,an(1≤ai≤5⋅105)—— 数组 a。
输出格式
Print one integer — the maximum possible number of elements with value c which can be obtained after performing operation described above.
输出一个整数——执行上述操作后所能得到的值为 c 的元素的最大可能数量。
输入输出样例
输入#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].
在第一个例子中,我们可以选择任意区间,且 k=0。数组将保持不变。
在第二个例子中,我们可以选择区间 [1,3],且 k=−4。数组将变为 [2,−2,2]。
输入解题思路,AI测评打分。不知道怎么写?