1743E - FTL
1743E - FTL
At any time, we have three possible choices: wait and shoot the first laser, the second laser and both lasers. Sometimes it makes sense to wait to both because you can deal s more damage than you would do by shooting both lasers separately.
The first claim: greedy won't work. Maybe there is a sufficiently smart greedy, we weren't able to come up with it. The second claim: brute force won't work. The funny thing is that it actually worked on the constraints up to 2000, but again, we couldn't code any sufficiently fast one for 5000.
Thus, let's try some dynamic programming. Since all the times are huge, we'd want to avoid having them as the states. What is small, however, is the durability of the enemy ship and the number of shots we have to make to destroy it.
Ideally, we'd like to have some — the smallest time to deal ii damage to the enemy ship. This way, would be the answer. Sadly, it's not immediately clear how to get rid of reload times completely. There might be states with different times until the charge with the same damage dealt, and we don't know which of those we want to keep.
Thus, let's make the state more complicated. Let be the smallest time it takes to deal ii damage if the last shot was from both lasers at the same time. This way we know the reload times of both lasers — they are full and .
, as moment 00 has both lasers zero charged as if after a shot.
What are the transitions? Well, now we have to shoot each laser multiple times, then wait until both are charged and shoot both. Both lasers can now be considered independent of each other.
Let the time between the previous double shot and the next one be some value . During this time, it never made sense to wait until shooting each laser. So we waited , shot the first laser, waited another , shot again, until we couldn't shoot anymore, since the laser wouldn't recharge in time before the double shot. Same for the second laser. Notice that if both and , then you could just decrease by 11 and shoot each laser the same number of times. Thus, only tt that are multiples of either or are optimal.
Thus, we can iterate over all possible waiting times tt. Just iterate over and for all ii from to . Having a fixed , calculate the number of shots of each laser, calculate the damage, go into the corresponding state.
It could also happen that the last shot before destroying the ship wasn't a double one. However, it still follows the same ideas. It means that each laser was shooting non-stop until the ship was destroyed. Thus, the destruction time is still a multiple of either of the reload times.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】