Codeforces Round 1031 (Div. 2)
A
Shashliks
Codeforces
800
原题
←B →
翻译中…

You are the owner of a popular shashlik restaurant, and your grill is the heart of your kitchen. However, the grill has a peculiarity: after cooking each shashlik, its temperature drops.

翻译中…

You need to cook as many portions of shashlik as possible, and you have an unlimited number of portions of two types available for cooking:

翻译中…
  • The first type requires a temperature of at least $a$ degrees at the start of cooking, and after cooking, the grill's temperature decreases by $x$ degrees.
  • The second type requires a temperature of at least $b$ degrees at the start of cooking, and after cooking, the grill's temperature decreases by $y$ degrees.
翻译中…

Initially, the grill's temperature is $k$ degrees. Determine the maximum total number of portions of shashlik that can be cooked.

翻译中…

Note that the grill's temperature can be negative.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The only line of each test case contains five integers $k$, $a$, $b$, $x$, and $y$ ($1 \le k, a, b, x, y \le 10^9$) — the initial temperature of the grill, the required temperature for cooking the first and second types of shashlik, respectively, as well as the temperature drop after cooking the first and second types of shashlik, respectively.

翻译中…

Output

翻译中…

For each test case, output a single integer — the maximum number of portions of shashlik that you can cook.

翻译中…

Note

翻译中…

In the first test case, it is advantageous to cook $7$ portions of the second type of shashlik; after that, the grill's temperature will be $3$ degrees, and we can cook one more portion of the first type of shashlik.

翻译中…

In the second test case, we cannot cook either type of shashlik because the grill is too cold.

翻译中…

In the fourth test case, it is advantageous to cook $8$ portions of the first type of shashlik; after that, it will be possible to cook another $2$ portions of the second type of shashlik.

翻译中…

样例

Input #1
5
10 3 4 2 1
1 10 10 1 1
100 17 5 2 3
28 14 5 2 4
277 5 14 1 3
Output #1
8
0
46
10
273
InputCopy OutputCopy
题目信息
题号
2113A
时间限制
1 s
内存限制
256 MB
标签
贪心
数学

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