#QHD0000029. Tăng số lần xuất hiện (Increasing Frequency)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tăng số lần xuất hiện (Increasing Frequency)
Increasing Frequency
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given an array and a target value , maximize the number of array elements equal to .
You may perform at most one operation: choose a consecutive segment , select an integer , and add to every element in that segment. Elements outside the segment remain unchanged. Choosing leaves the array unchanged.
Output the largest possible frequency of after the operation.
Input
The first line contains and .
The second line contains the array of integers.
Output
Print the maximum achievable number of occurrences of .
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
3 2
6 2 6
Output
2
Explanation
Initially has one occurrence of . Adding to the first element produces , with two occurrences. Turning both values into would also change the middle , so three occurrences are impossible.