CF1400B.RPG Protagonist
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course.
You decided to rob a town's blacksmith and you take a follower with you. You can carry at most p units and your follower — at most f units.
In the blacksmith shop, you found cnts swords and cntw war axes. Each sword weights s units and each war axe — w units. You don't care what to take, since each of them will melt into one steel ingot.
What is the maximum number of weapons (both swords and war axes) you and your follower can carry out from the shop?
输入格式
The first line contains a single integer t ( 1≤t≤104 ) — the number of test cases.
The first line of each test case contains two integers p and f ( 1≤p,f≤109 ) — yours and your follower's capacities.
The second line of each test case contains two integers cnts and cntw ( 1≤cnts,cntw≤2⋅105 ) — the number of swords and war axes in the shop.
The third line of each test case contains two integers s and w ( 1≤s,w≤109 ) — the weights of each sword and each war axe.
It's guaranteed that the total number of swords and the total number of war axes in all test cases don't exceed 2⋅105 .
输出格式
For each test case, print the maximum number of weapons (both swords and war axes) you and your follower can carry.
输入输出样例
输入#1
3 33 27 6 10 5 6 100 200 10 10 5 5 1 19 1 3 19 5
输出#1
11 20 3
说明/提示
In the first test case:
- you should take 3 swords and 3 war axes: 3⋅5+3⋅6=33≤33
- and your follower — 3 swords and 2 war axes: 3⋅5+2⋅6=27≤27 .
3+3+3+2=11 weapons in total. In the second test case, you can take all available weapons even without your follower's help, since 5⋅10+5⋅10≤100 .
In the third test case, you can't take anything, but your follower can take 3 war axes: 3⋅5≤19 .