Playrix Codescapes Cup (Codeforces Round 413, rated, Div. 1 + Div. 2)
D
Field expansion
Codeforces
2100
原题
← CE →
翻译中…

In one of the games Arkady is fond of the game process happens on a rectangular field. In the game process Arkady can buy extensions for his field, each extension enlarges one of the field sizes in a particular number of times. Formally, there are $*n*$ extensions, the $*i*$-th of them multiplies the width or the length (by Arkady's choice) by $*a*_{*i*}$. Each extension can't be used more than once, the extensions can be used in any order.

翻译中…

Now Arkady's field has size $*h* × *w*$. He wants to enlarge it so that it is possible to place a rectangle of size $*a* × *b*$ on it (along the width or along the length, with sides parallel to the field sides). Find the minimum number of extensions needed to reach Arkady's goal.

翻译中…

Input

翻译中…

The first line contains five integers $*a*$, $*b*$, $*h*$, $*w*$ and $*n*$ ($1 ≤ *a*, *b*, *h*, *w*, *n* ≤ 100 000$) — the sizes of the rectangle needed to be placed, the initial sizes of the field and the number of available extensions.

翻译中…

The second line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($2 ≤ *a*_{*i*} ≤ 100 000$), where $*a*_{*i*}$ equals the integer a side multiplies by when the $*i*$-th extension is applied.

翻译中…

Output

翻译中…

Print the minimum number of extensions needed to reach Arkady's goal. If it is not possible to place the rectangle on the field with all extensions, print -1. If the rectangle can be placed on the initial field, print 0.

翻译中…

Note

翻译中…

In the first example it is enough to use any of the extensions available. For example, we can enlarge $*h*$ in $5$ times using the second extension. Then $*h*$ becomes equal $10$ and it is now possible to place the rectangle on the field.

翻译中…

样例

Input #1
3 3 2 4 4
2 5 4 10
Output #1
1
InputCopy OutputCopy
Input #2
3 3 3 3 5
2 3 5 4 2
Output #2
0
InputCopy OutputCopy
Input #3
5 5 1 2 3
2 2 3
Output #3
-1
InputCopy OutputCopy
Input #4
3 4 1 1 3
2 3 2
Output #4
3
InputCopy OutputCopy
题目信息
题号
799D
时间限制
1 s
内存限制
256 MB
标签
暴力
动态规划
折半搜索

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。