Problem 3820 --Pty plays game

3820: Pty plays game

"
Time Limit $5$ 秒/Second(s) Memory Limit $128$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Pty is playing a game, where he is leading a team of soldiers. He is facing a challenge in the game. He plans to complete the challenge x days later. 

The monster is also leading a team of soldiers. And to complete the challenge Pty should beat these soldiers. 

The battle will execute as follows. At first, the first soldier of both teams will fight first. When a soldier’s hit points becomes 0,the soldier will be replaced by the next soldier in the same team.A team is considered a victory only if there is any soldier alive but nobody is alive in the opposite team finally. 

The soldier x have hx hit points and can cause dx damage to the enemy per second. Notice that the seconds of a fight may not be an integer. 

Both Pty and the monster will train their soldiers continuously, so the hit points and damage per second of all the soldiers will increase every day. 

Pty wants to know the minimum x that he will complete the challenge if it take place on x days later.

If Pty can’t win the monster in 1018 days, please print none . Specially, if Pty can win now, the answer is 0.
An integer T in the first line, it is the number of tesecases. And there are T cases later.

In each case, two integers in the first line n,m, which is the numbers of soldiers in the Pty’s team and the monster’s team. 

In the next n lines, each line contains 4 integers. They means the hit point, the increment of hit point every day, the damage and the increment of damage every day. 

In the next m lines, also contains 4 integers. They are the information of the soldier in the monster’s team. 

(1≤n,m≤105,∑(n+m)≤2×106,0≤hx,dx≤106,0≤increment≤103)
For each test case, output ’none’ or integer means the minimum of x in one line.
2
3 2
2 3 1 3
3 2 4 3
1 2 2 3
3 3 4 2
4 1 1 3
1 1
1 1 1 1
1 1 1 1
1
none

推荐代码 查看3820 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛