Under construction

Still being built. Things may change

Creative Accounting

Interview

Time limit5sMemory limit1024 MB

Summary
Given daily profits and a range of segment sizes, find the minimum and maximum count of profitable segments over all sizes and starting days.
Level

Medium4 of 10

Topics
Prefix sum, Brute force, Array
Solved
No attempts yet

Problem

When accounting for the profit of a business, we can divide consecutive days into fixed-size segments and calculate each segment's profit as the sum of all its daily profits. For example, we could choose seven-day segments to do our accounting in terms of weekly profit. We also have the flexibility of choosing a segment's starting day. For example, for weekly profit we can start a week on a Sunday, Monday, or even Wednesday. Choosing different segment starting days may sometimes change how the profit looks on the books, making it more (or less) attractive to investors.

As an example, we can divide ten consecutive days of profit (or loss, which we denote as negative profit) into three-day segments as such:

3,2,−7 ∣ 5,4,1 ∣ 3,0,−3 ∣ 53, 2, {-7} \:|\: 5, 4, 1 \:|\: 3, 0, {-3} \:|\: 5

This gives us four segments with profit −2,10,0,5-2, 10, 0, 5. For the purpose of this division, partial segments with fewer than the fixed segment size are allowed at the beginning and at the end. We say a segment is profitable if it has a strictly positive profit. In the above example, only two out of the four segments are profitable.

If we try a different starting day, we can obtain:

3,2 ∣ −7,5,4 ∣ 1,3,0 ∣ −3,53, 2 \:|\: {-7}, 5, 4 \:|\: 1, 3, 0 \:|\: {-3}, 5

This gives us four segments with profit 5,2,4,25, 2, 4, 2. All four segments are profitable, which makes our business look much more consistent.

You are given a list of consecutive days of profit, as well as an integer range. If we can choose any segment size within that range and any starting day for our accounting, what is the minimum and maximum number of profitable segments that we can have?

Input

The first line of input has three space-separated integers nn, ℓ\ell and hh (1≤ℓ≤h≤n≤3×1041 \le \ell \le h \le n \le 3 \times 10^4, h−ℓ≤1 000h - \ell \le 1\,000), where nn is the number of days in the books, ℓ\ell is the minimum possible choice of segment size, and hh is the maximum possible choice of segment size.

Each of the next nn lines contains a single integer pp (−104≤p≤104-10^4 \le p \le 10^4). These are the daily profits, in order.

Output

Output on a single line two space-separated integers minmin and maxmax, where minmin is the minimum number of profitable segments possible, and maxmax is the maximum number of profitable segments possible. Both minmin and maxmax are taken over all possible choices of segment size between ℓ\ell and hh and all possible choices of starting day.

Examples1

  1. Example 1

    Input
    10 3 5
    3
    2
    -7
    5
    4
    1
    3
    0
    -3
    5
    
    Expected output
    2 4