PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000346. Gây quỹ vì thiên nhiên (Save the Nature)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Gây quỹ vì thiên nhiên (Save the Nature)

Save the Nature

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You have NN ticket prices P1,P2,…,PNP_1,P_2,\ldots,P_N and may rearrange the selling order arbitrarily.

The first program receives x%x\% of a ticket sold at a position divisible by aa; the second receives y%y\% at positions divisible by bb. A position divisible by both yields (x+y)%(x+y)\% in total. Ticket prices are multiples of 100, so every contribution is integral.

Find the smallest number of tickets to sell so that the total donation is at least KK, or print -1 if it is impossible even after selling all tickets.

PHOJ adaptation: one independent query per input file instead of the multiple-query wrapper of the original Codeforces statement.

Input

Line 1: NN.

Line 2: NN prices P1,…,PNP_1,\ldots,P_N.

Line 3: x ax\ a.

Line 4: y by\ b.

Line 5: KK.

Output

Print the minimum number of tickets, or -1.

Subtasks

  • Subtask 1 (20 points): 1≤N≤81\le N\le 8, 100≤Pi≤104100\le P_i\le 10^4, Pi≡0(mod100)P_i\equiv0\pmod{100}, 1≤x,y1\le x,y, x+y≤100x+y\le100, 1≤a,b≤N1\le a,b\le N, 1≤K≤1061\le K\le 10^6.
  • Subtask 2 (30 points): 1≤N≤20001\le N\le 2000, 100≤Pi≤106100\le P_i\le 10^6, Pi≡0(mod100)P_i\equiv0\pmod{100}, 1≤x,y1\le x,y, x+y≤100x+y\le100, 1≤a,b≤N1\le a,b\le N, 1≤K≤10101\le K\le10^{10}.
  • Subtask 3 (50 points): 1≤N≤2⋅1051\le N\le 2\cdot10^5, 100≤Pi≤109100\le P_i\le10^9, Pi≡0(mod100)P_i\equiv0\pmod{100}, 1≤x,y1\le x,y, x+y≤100x+y\le100, 1≤a,b≤N1\le a,b\le N, 1≤K≤10141\le K\le10^{14}.

Examples

Example 1

Input

8
100 200 100 200 100 200 100 100
10 2
15 3
107

Output

6

Explanation

For the first six tickets, positions 2, 3, 4, 6 contribute. One optimal arrangement obtains 110, while five tickets cannot reach 107.

Example 2

Input

5
200 100 100 100 100
69 5
31 2
90

Output

4

Explanation

Among the first four tickets, positions 2 and 4 receive 31%. Assign prices 200 and 100 to get 93, reaching the target; three tickets do not suffice.