CF1005E2 Median on Segments (General Case Edition)

题目描述

#### 题目翻译 给定长度为 $n$ 的序列($1 \le n \le 2 \times 10^5$),求中位数为 $m$ 的子段个数(子段长度为偶数时,取其 $\dfrac{k}{2}$ 项,$k$ 为子段长度)。

输入格式

第一行两个整数,$n,m$。 第二行 $n$ 个整数表示序列$(1

输出格式

输出满足要求的方案数。

说明/提示

In the first example, the suitable pairs of indices are: $ (1, 3) $ , $ (1, 4) $ , $ (1, 5) $ , $ (2, 2) $ , $ (2, 3) $ , $ (2, 5) $ , $ (4, 5) $ and $ (5, 5) $ .