当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5722:Jewelry

题目描述
After all the difficulties, Psyche and Cupid are finally getting married.

No ordinary pearls can hold Cupid's love for Psyche. So he has collected the Jewelry of Gods at the top of Mount Olympus to make her a chain.

There are $ n $ beads on the chain. The $ i $-th bead is of the type $ A_i $.

Being pretty in appearance and generous in her heart, Psyche decides to give one consecutive part of the chain to her mother.

To meet her mother's particular taste, that part must have at least one type of bead that appears $ x $ times exactly.

Psyche wants to know the number of ways to choose a part of the chain for her mother.

Note that two parts $[L_1, R_1]$ and $[L_2, R_2]$ are different only if $ L_1 \neq L_2 $ or $ R_1 \neq R_2 $.
输入解释
The first line of the input contains an integer $ T $ $ (1 \le T \le 15) $, which denotes the number of test cases.

For each test case, the first line contains two integers $ n,x $ $ (1 \le n \le 10 ^ 5, 1 \le x \le n) $.

The second line contains $ n $ integers, the $ i $-th integer denotes $ A_i $ $ (0 \le A_i \le 10 ^ 9) $.
输出解释
For each test case, print an integer which denotes the number of parts Psyche can choose.
输入样例
2
3 1
1 2 1
4 2
2 3 2 2
输出样例
6
3

提示
In the first example, all solutions all valid.

In the second example, solution $ [1,3], [2,4], [3,4] $ have a type of beed, 2, that appears twice exactly.
来自杭电HDUOJ的附加信息
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5722

最后修改于 2020-10-25T23:25:06+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
8000/4000MS(Java/Others) 262144/262144K(Java/Others)