CF1400B.RPG Protagonist

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

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 pp units and your follower — at most ff units.

In the blacksmith shop, you found cntscnt_s swords and cntwcnt_w war axes. Each sword weights ss units and each war axe — ww 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?

你正在玩一款2010年代的RPG游戏。你打算提升自己的锻造技能,因此需要尽可能多的资源。那么如何获取资源呢?当然是靠偷啦!

你决定抢劫小镇上的铁匠铺,并带了一名随从同行。你最多能携带 pp 单位重量,而你的随从最多能携带 ff 单位重量。

在铁匠铺中,你发现了 cntscnt_s 把剑和 cntwcnt_w 把战斧。每把剑重 ss 单位,每把战斧重 ww 单位。你并不在意具体拿什么,因为无论剑还是战斧,熔炼后都只会得到一块钢锭。

你和你的随从最多能从铁匠铺中带走多少件武器(剑和战斧总数)?

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

The first line of each test case contains two integers pp and ff (1≤p,f≤1091 \le p, f \le 10^9) — yours and your follower's capacities.

The second line of each test case contains two integers cntscnt_s and cntwcnt_w (1≤cnts,cntw≤2⋅1051 \le cnt_s, cnt_w \le 2 \cdot 10^5) — the number of swords and war axes in the shop.

The third line of each test case contains two integers ss and ww (1≤s,w≤1091 \le s, w \le 10^9) — 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⋅1052 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 测试用例的数量。

每个测试用例的第一行包含两个整数 pp 和 ff(1≤p,f≤1091 \le p, f \le 10^9)—— 你和你的追随者的负重上限。

每个测试用例的第二行包含两个整数 cntscnt_s 和 cntwcnt_w(1≤cnts,cntw≤2⋅1051 \le cnt_s, cnt_w \le 2 \cdot 10^5)—— 商店中剑与战斧的数量。

每个测试用例的第三行包含两个整数 ss 和 ww(1≤s,w≤1091 \le s, w \le 10^9)—— 每把剑与每把战斧的重量。

保证所有测试用例中剑的总数与战斧的总数均不超过 2⋅1052 \cdot 10^5。

输出格式

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 33 swords and 33 war axes: 3⋅5+3⋅6=33≤333 \cdot 5 + 3 \cdot 6 = 33 \le 33
  • and your follower — 33 swords and 22 war axes: 3⋅5+2⋅6=27≤273 \cdot 5 + 2 \cdot 6 = 27 \le 27.

3+3+3+2=113 + 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≤1005 \cdot 10 + 5 \cdot 10 \le 100.

In the third test case, you can't take anything, but your follower can take 33 war axes: 3⋅5≤193 \cdot 5 \le 19.

在第一个测试用例中:

  • 你需要拿 33 把剑和 33 把战斧:3⋅5+3⋅6=33≤333 \cdot 5 + 3 \cdot 6 = 33 \le 33;
  • 而你的追随者则拿 33 把剑和 22 把战斧:3⋅5+2⋅6=27≤273 \cdot 5 + 2 \cdot 6 = 27 \le 27。

总共拿了 3+3+3+2=113 + 3 + 3 + 2 = 11 件武器。

在第二个测试用例中,即使没有追随者的帮助,你也可以拿走所有可用的武器,因为 5⋅10+5⋅10≤1005 \cdot 10 + 5 \cdot 10 \le 100。

在第三个测试用例中,你无法拿取任何武器,但你的追随者可以拿 33 把战斧:3⋅5≤193 \cdot 5 \le 19。

输入解题思路,AI测评打分。不知道怎么写?

首页