cswork / OAOpen practice workspace

Akuna CapitalOA #1

Network Formation

Estimated MediumJudge-ready

Topics (AI-labelled)GreedyTwo Pointers

Form networks from several non-overlapping contiguous ranges of computers, in the original order. Each network must contain at least minComps computers and have a total speed of at least speedThreshold; computers not used in any network may be skipped. Find the maximum number of networks. Speeds are non-negative integers.

Input

The first line contains n, minComps and speedThreshold; the second line contains n non-negative integers speed[i]. Site ranges: 1≤n≤200000, 1≤minComps≤n, 0≤speed[i]≤10^9, 0≤speedThreshold≤10^14.

Output

Output the maximum number of networks that can be formed.

Example 1

Input:

6 2 15
5 7 9 12 10 13

Output:

2

Example 2

Input:

1 1 1
1

Output:

1

Example 3

Input:

3 2 1
0 0 0

Output:

0

Editorial

Loading solution…