#P15858. [蓝桥杯第二届国际赛] 星际争霸 2

    ID: 19914 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度提高+/省选− 上传者: 标签>动态规划 DP2018动态规划优化蓝桥杯国赛

[蓝桥杯第二届国际赛] 星际争霸 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:

  1. Build a factory.
  2. Let every existing factory build one warship.

However, your opponent will launch attacks on you. Each wave of attack is in the form (t,x)(t, x), meaning that at the end of the tt-th time unit, your opponent will send xx warships to attack. If at that time your number of warships is less than xx, you lose. Otherwise, your number of warships will decrease by xx. 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 TT, the number of test cases.

For each test case, the first line contains a positive integer nn.

The next nn lines each contain two numbers ti,xit_i, x_i, describing one wave of attack (note: they are not necessarily given in time order). It is guaranteed that for i≠ji \ne j, ti≠tjt_i \ne t_j.

Output Format

For each test case:

If you can win, output "Victory". On the second line output "Max warship:$ans_1$", where ans1ans_1 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 ans2ans_2 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 2020 test points, each worth 55 points, with the following properties:

Test points 1∼21\sim 2: 1≤n≤101 \le n \le 10, 1≤ti≤101 \le t_i \le 10.

Test points 3∼63\sim 6: 1≤n≤5001 \le n \le 500, 1≤ti≤50001 \le t_i \le 5000.

Test points 7∼87\sim 8: 1≤n≤51 \le n \le 5.

Test points 9∼109\sim 10: 1≤n≤50001 \le n \le 5000.

Test points 11∼1311\sim 13: It is guaranteed that the first line of the answer for each test case is always Defeat.

Test points 14∼1614\sim 16: It is guaranteed that the first line of the answer for each test case is always Victory.

Test points 17∼2017\sim 20: No additional constraints.

For all data: T=10T = 10, 1≤n≤1051 \le n \le 10^5, 1≤ti≤1061 \le t_i \le 10^6, 1≤xi≤10181 \le x_i \le 10^{18}, ∑xi≤1018\sum x_i \le 10^{18}.

Translated by ChatGPT 5