GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Monday, 17 October 2022

[Solution] FTL Codeforces Solution | Solution Codeforces



E. FTL
time limit per test
4 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

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:

  • pi — the power of the laser;
  • ti — 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 (Ps) damage (i. e. (Ps) gets subtracted from its durability), where P is the total power of the lasers that Monocarp shoots (i. e. pi if he only shoots laser i and p1+p2 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?

Input

The first line contains two integers p1 and t1 (2p150001t11012) — the power and the reload time of the first laser.

The second line contains two integers p2 and t2 (2p250001t21012) — the power and the reload time of the second laser.

The third line contains two integers h and s (1h50001s<min(p1,p2)) — the durability and the shield capacity of an enemy spaceship. Note that the last constraint implies that Monocarp will always be able to

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

 destroy an enemy spaceship.

Output

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

Note

In the first example, Monocarp waits for both lasers to charge, then shoots both lasers at 10, they deal (5+41)=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 (109)=1 damage each time.

No comments:

Post a Comment