#P1627. [CQOI2009] 中位数
[CQOI2009] 中位数
Description
Given a permutation of , count how many contiguous subsequences of odd length have the median equal to . The median is the number that lies in the middle after sorting all elements in nondecreasing order.
Input Format
The first line contains two positive integers and . The second line contains a permutation of .
Output Format
Output a single integer: the number of contiguous subsequences whose median is .
7 4
5 7 2 4 3 1 6
4
Hint
Constraints
For of the testdata, ;
For of the testdata, ;
For of the testdata, 。
Translated by ChatGPT 5
京公网安备 11011102002149号