309842: CF1743E. FTL

Memory Limit:512 MB Time Limit:4 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

FTL

题意翻译

有两艘飞船,第 $i$ 艘飞船($i∈[1,2]$)的攻击力为 $p_i$,每一次攻击的充能时间为 $t_i$,一开始两艘飞船没有充能。 现在要打败敌方飞船,敌方飞船的血量为 $h$,防御力为 $s$。对于一次攻击力为 $P$ 的攻击,敌方飞船的血量会减少 $(P-s)$。每一次攻击可以是一艘飞船单独攻击,也可以是两艘飞船同时攻击(当一艘飞船完成充能后,可以等待另一艘飞船充能,然后再一起攻击)。两艘飞船一起攻击的攻击力为 $p_1+p_2$。 打败敌方飞船的条件是使得敌方飞船的血量小于等于 $0$。现在依次给出 $p_1,t_1,p_2,t_2,h,s$,求出最少需要多少时间能够打败敌方飞船。

题目描述

Monocarp is playing a video game. In the game, he controls a spaceship and has to destroy an enemy spaceship. Monocarp has two lasers installed on his spaceship. Both lasers $ 1 $ and $ 2 $ have two values: - $ p_i $ — the power of the laser; - $ t_i $ — the reload time of the laser. When a laser is fully charged, Monocarp can either shoot it or wait for the other laser to charge and shoot both of them at the same time. An enemy spaceship has $ h $ durability and $ s $ shield capacity. When Monocarp shoots an enemy spaceship, it receives $ (P - s) $ damage (i. e. $ (P - s) $ gets subtracted from its durability), where $ P $ is the total power of the lasers that Monocarp shoots (i. e. $ p_i $ if he only shoots laser $ i $ and $ p_1 + p_2 $ if he shoots both lasers at the same time). An enemy spaceship is considered destroyed when its durability becomes $ 0 $ or lower. Initially, both lasers are zero charged. What's the lowest amount of time it can take Monocarp to destroy an enemy spaceship?

输入输出格式

输入格式


The first line contains two integers $ p_1 $ and $ t_1 $ ( $ 2 \le p_1 \le 5000 $ ; $ 1 \le t_1 \le 10^{12} $ ) — the power and the reload time of the first laser. The second line contains two integers $ p_2 $ and $ t_2 $ ( $ 2 \le p_2 \le 5000 $ ; $ 1 \le t_2 \le 10^{12} $ ) — the power and the reload time of the second laser. The third line contains two integers $ h $ and $ s $ ( $ 1 \le h \le 5000 $ ; $ 1 \le s < \min(p_1, p_2) $ ) — the durability and the shield capacity of an enemy spaceship. Note that the last constraint implies that Monocarp will always be able to destroy an enemy spaceship.

输出格式


Print a single integer — the lowest amount of time it can take Monocarp to destroy an enemy spaceship.

输入输出样例

输入样例 #1

5 10
4 9
16 1

输出样例 #1

20

输入样例 #2

10 1
5000 100000
25 9

输出样例 #2

25

说明

In the first example, Monocarp waits for both lasers to charge, then shoots both lasers at $ 10 $ , they deal $ (5 + 4 - 1) = 8 $ damage. Then he waits again and shoots lasers at $ 20 $ , dealing $ 8 $ more damage. In the second example, Monocarp doesn't wait for the second laser to charge. He just shoots the first laser $ 25 $ times, dealing $ (10 - 9) = 1 $ damage each time.

Input

题意翻译

有两艘飞船,第 $i$ 艘飞船($i∈[1,2]$)的攻击力为 $p_i$,每一次攻击的充能时间为 $t_i$,一开始两艘飞船没有充能。 现在要打败敌方飞船,敌方飞船的血量为 $h$,防御力为 $s$。对于一次攻击力为 $P$ 的攻击,敌方飞船的血量会减少 $(P-s)$。每一次攻击可以是一艘飞船单独攻击,也可以是两艘飞船同时攻击(当一艘飞船完成充能后,可以等待另一艘飞船充能,然后再一起攻击)。两艘飞船一起攻击的攻击力为 $p_1+p_2$。 打败敌方飞船的条件是使得敌方飞船的血量小于等于 $0$。现在依次给出 $p_1,t_1,p_2,t_2,h,s$,求出最少需要多少时间能够打败敌方飞船。

Output

**题目大意:**
在游戏中,有两艘飞船,每艘飞船有自己的攻击力 \( p_i \) 和充能时间 \( t_i \)。它们需要击败一艘敌舰,敌舰的血量为 \( h \) 和防御力 \( s \)。每次攻击可以是一艘飞船单独攻击,也可以两艘同时攻击。单次攻击力为 \( P \) 时,敌舰血量减少 \( P-s \)。要打败敌舰,就是要使其血量降到0或以下。给出 \( p_1, t_1, p_2, t_2, h, s \),求最少需要多少时间打败敌舰。

**输入数据格式:**
- 第一行:两个整数 \( p_1 \) 和 \( t_1 \),分别是第一艘飞船的攻击力和充能时间。
- 第二行:两个整数 \( p_2 \) 和 \( t_2 \),分别是第二艘飞船的攻击力和充能时间。
- 第三行:两个整数 \( h \) 和 \( s \),分别是敌舰的血量和防御力。

**输出数据格式:**
- 一个整数,表示打败敌舰所需的最少时间。

**输入输出样例:**
**输入样例 #1:**
```
5 10
4 9
16 1
```
**输出样例 #1:**
```
20
```
**输入样例 #2:**
```
10 1
5000 100000
25 9
```
**输出样例 #2:**
```
25
```

**说明:**
- 在第一个样例中,等待两艘飞船充能后同时攻击,每次攻击造成 \( (5 + 4 - 1) = 8 \) 点伤害。共需20单位时间。
- 在第二个样例中,只使用第一艘飞船攻击,共需25次,每次造成 \( (10 - 9) = 1 \) 点伤害。共需25单位时间。**题目大意:** 在游戏中,有两艘飞船,每艘飞船有自己的攻击力 \( p_i \) 和充能时间 \( t_i \)。它们需要击败一艘敌舰,敌舰的血量为 \( h \) 和防御力 \( s \)。每次攻击可以是一艘飞船单独攻击,也可以两艘同时攻击。单次攻击力为 \( P \) 时,敌舰血量减少 \( P-s \)。要打败敌舰,就是要使其血量降到0或以下。给出 \( p_1, t_1, p_2, t_2, h, s \),求最少需要多少时间打败敌舰。 **输入数据格式:** - 第一行:两个整数 \( p_1 \) 和 \( t_1 \),分别是第一艘飞船的攻击力和充能时间。 - 第二行:两个整数 \( p_2 \) 和 \( t_2 \),分别是第二艘飞船的攻击力和充能时间。 - 第三行:两个整数 \( h \) 和 \( s \),分别是敌舰的血量和防御力。 **输出数据格式:** - 一个整数,表示打败敌舰所需的最少时间。 **输入输出样例:** **输入样例 #1:** ``` 5 10 4 9 16 1 ``` **输出样例 #1:** ``` 20 ``` **输入样例 #2:** ``` 10 1 5000 100000 25 9 ``` **输出样例 #2:** ``` 25 ``` **说明:** - 在第一个样例中,等待两艘飞船充能后同时攻击,每次攻击造成 \( (5 + 4 - 1) = 8 \) 点伤害。共需20单位时间。 - 在第二个样例中,只使用第一艘飞船攻击,共需25次,每次造成 \( (10 - 9) = 1 \) 点伤害。共需25单位时间。

加入题单

算法标签: