Under construction

Still being built. Things may change

Military Enlistment

Interview

Time limit1sMemory limit1024 MB

Summary
Given daily volunteer points and a blood donation that blocks the next D days, find the fewest donations needed to reach at least M points, or -1 if impossible.
Level

Medium5 of 10

Topics
Dynamic programming, Prefix sum, Greedy
Solved
No attempts yet

Problem

Jinjin, who has reached the age of military service, wants to apply for the Republic of Korea Air Force recruit program. To be accepted, he needs bonus points, and because the Air Force has become more popular recently, he must collect at least MM points through volunteer work or blood donation.

There are NN days left until the application deadline. On day ii, he can take part in volunteer work that gives sis_i bonus points. He can donate blood on any day from 11 to NN, and each donation gives him AA bonus points. However, after a donation, he cannot donate blood or do volunteer work for DD days, counting the donation day itself, so that he can rest enough.

Jinjin dislikes blood donation, so he wants to collect at least MM bonus points while donating as few times as possible. Find the minimum number of blood donations needed to collect at least MM bonus points by the application deadline.

Input

The first line contains two integers NN and MM, separated by a space, where NN is the number of days left until the deadline and MM is the bonus points needed to pass. (1≤N≤10001 \le N \le 1000, 1≤M≤1071 \le M \le 10^7)

The second line contains NN integers s1,⋯ ,sNs_1, \cdots, s_N, separated by spaces, where sis_i is the bonus points from volunteer work on day ii. (1≤si≤10001 \le s_i \le 1000)

The third line contains two integers AA and DD, separated by a space, where AA is the bonus points from one blood donation and DD is the number of days of rest needed after a donation. (1≤A≤100001 \le A \le 10000, 1≤D≤N1 \le D \le N)

Output

Print the minimum number of blood donations needed to collect at least MM bonus points.

If it is impossible to collect at least MM bonus points, print -1.

Examples2

  1. Example 1

    Input
    5 34
    1 4 8 6 3
    10 2
    
    Expected output
    2
    
  2. Example 2

    Input
    4 21
    3 5 4 6
    8 2
    
    Expected output
    -1