#P15858. [蓝桥杯第二届国际赛] 星际争霸 2
[蓝桥杯第二届国际赛] 星际争霸 2
Problem Description
There is a game called StarCraft 2. In this game, you need to build some unit-producing buildings, and then use these buildings to produce your troops, and finally defeat your opponent.
Consider a simplified version of StarCraft 2. At the beginning, you have nothing. In each unit of time, you can choose one of the following two actions:
- Build a factory.
- Let every existing factory build one warship.
However, your opponent will launch attacks on you. Each wave of attack is in the form , meaning that at the end of the -th time unit, your opponent will send warships to attack. If at that time your number of warships is less than , you lose. Otherwise, your number of warships will decrease by . If you successfully defend against all attacks, you win.
Given all attack information from your opponent, determine whether you can win. If you can, find the maximum number of warships you can have remaining after the opponent’s last attack. If you cannot, find the maximum number of attacks you can withstand.
Input Format
This problem contains multiple test cases.
The first line contains a positive integer , the number of test cases.
For each test case, the first line contains a positive integer .
The next lines each contain two numbers , describing one wave of attack (note: they are not necessarily given in time order). It is guaranteed that for , .
Output Format
For each test case:
If you can win, output "Victory". On the second line output "Max warship:$ans_1$", where is the maximum number of warships you can have remaining after the last wave of attack.
Otherwise, output "Defeat". On the second line output "Max level:$ans_2$", where is the maximum number of attacks you can withstand.
2
3
3 2
5 3
10 15
3
4 3
8 10
9 12
Victory
Max warship:1
Defeat
Max level:2
Hint
Constraints
This problem has test points, each worth points, with the following properties:
Test points : , .
Test points : , .
Test points : .
Test points : .
Test points : It is guaranteed that the first line of the answer for each test case is always Defeat.
Test points : It is guaranteed that the first line of the answer for each test case is always Victory.
Test points : No additional constraints.
For all data: , , , , .
Translated by ChatGPT 5