"""
https://www.lanqiao.cn/problems/1621/learning/?page=1&first_category_id=1&problem_id=1621
"""
import os
import sys
# 请在此输入您的代码
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
left, right = 0, 0
# [left, right)区间内大于m的个数
cnt = 0
ans = 0
while left < n:
# 不断扩展右端点
while right < n and cnt < k:
if a[right] >= m:
cnt += 1
right += 1
if cnt >= k:
# 此时的合法区间为[left, right - 1]
ans += n - right + 1
# 左指针右走1步, 删除元素
if a[left] >= m:
cnt -= 1
left += 1
print(ans)
蓝桥杯-挑选子串
最新推荐文章于 2024-07-11 23:38:50 发布