CF1743E.FTL

提高+/省选-

通过率:0%

时间限制:4.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 11 and 22 have two values:

  • pip_i — the power of the laser;
  • tit_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 hh durability and ss shield capacity. When Monocarp shoots an enemy spaceship, it receives (P−s)(P - s) damage (i. e. (P−s)(P - s) gets subtracted from its durability), where PP is the total power of the lasers that Monocarp shoots (i. e. pip_i if he only shoots laser ii and p1+p2p_1 + p_2 if he shoots both lasers at the same time). An enemy spaceship is considered destroyed when its durability becomes 00 or lower.

Initially, both lasers are zero charged.

What's the lowest amount of time it can take Monocarp to destroy an enemy spaceship?

Monocarp 正在玩一款视频游戏。在游戏中,他操控一艘宇宙飞船,需要摧毁一艘敌方宇宙飞船。

Monocarp 的宇宙飞船上安装了两台激光器,分别记为激光器 11 和激光器 22。每台激光器均具有两个参数:

  • pip_i —— 激光器的功率;
  • tit_i —— 激光器的充能时间(即两次射击之间的最短时间间隔)。

当某台激光器完全充能后,Monocarp 可以选择立即发射该激光器,或者等待另一台激光器也完成充能,然后同时发射两台激光器。

敌方宇宙飞船具有 hh 点耐久度(durability)和 ss 点护盾容量(shield capacity)。当 Monocarp 向敌方飞船发射激光时,飞船受到 (P−s)(P - s) 点伤害(即其耐久度减少 (P−s)(P - s)),其中 PP 为 Monocarp 此次发射的所有激光器的总功率(即:若仅发射激光器 ii,则 P=piP = p_i;若同时发射两台激光器,则 P=p1+p2P = p_1 + p_2)。当敌方飞船的耐久度降至 00 或更低时,即视为被摧毁。

初始时刻,两台激光器的充能进度均为 00。

问:Monocarp 摧毁敌方宇宙飞船所需的最短时间是多少?

输入格式

The first line contains two integers p1p_1 and t1t_1 (2≤p1≤50002 \le p_1 \le 5000; 1≤t1≤10121 \le t_1 \le 10^{12}) — the power and the reload time of the first laser.

The second line contains two integers p2p_2 and t2t_2 (2≤p2≤50002 \le p_2 \le 5000; 1≤t2≤10121 \le t_2 \le 10^{12}) — the power and the reload time of the second laser.

The third line contains two integers hh and ss (1≤h≤50001 \le h \le 5000; 1≤s<min⁡(p1,p2)1 \le s \lt \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.

第一行包含两个整数 p1p_1 和 t1t_1(2≤p1≤50002 \le p_1 \le 5000;1≤t1≤10121 \le t_1 \le 10^{12})—— 分别表示第一台激光器的功率和装填时间。

第二行包含两个整数 p2p_2 和 t2t_2(2≤p2≤50002 \le p_2 \le 5000;1≤t2≤10121 \le t_2 \le 10^{12})—— 分别表示第二台激光器的功率和装填时间。

第三行包含两个整数 hh 和 ss(1≤h≤50001 \le h \le 5000;1≤s<min⁡(p1,p2)1 \le s \lt \min(p_1, p_2))—— 分别表示敌方飞船的耐久度和护盾容量。注意,最后一个约束条件意味着 Monocarp 总能摧毁一艘敌方飞船。

输出格式

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

输出一个整数——Monocarp 摧毁敌方宇宙飞船所需的最短时间。

输入输出样例

  • 输入#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 1010, they deal (5+4−1)=8(5 + 4 - 1) = 8 damage. Then he waits again and shoots lasers at 2020, dealing 88 more damage.

In the second example, Monocarp doesn't wait for the second laser to charge. He just shoots the first laser 2525 times, dealing (10−9)=1(10 - 9) = 1 damage each time.

在第一个例子中,Monocarp 等待两束激光均完成充能,然后在时刻 1010 同时发射两束激光,造成 (5+4−1)=8(5 + 4 - 1) = 8 点伤害。接着他再次等待,并在时刻 2020 发射激光,又造成 88 点伤害。

在第二个例子中,Monocarp 并不等待第二束激光完成充能。他仅连续发射第一束激光 2525 次,每次造成 (10−9)=1(10 - 9) = 1 点伤害。

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

首页