while True:
    try:
        line = input()
        if not line:
            break
        n, t, c = list(map(int, line.strip().split()))
        crime_values = list(map(int,input().strip().split()))
        window_sum = 0
        ans = 0
        for idx, a in enumerate(crime_values):
            if idx < c:
                window_sum += a
                if idx == c-1 and window_sum <= t:
                    ans += 1
                continue
            window_sum = window_sum + a - crime_values[idx-c]
            if window_sum <= t:
                ans += 1

        print(ans)
    except:
        break

滑动窗口

python3实现。