P15858 [Lanqiao Cup 2nd International Contest] StarCraft 2 (No testdata yet).

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)$, meaning that at the end of the $t$-th time unit, your opponent will send $x$ warships to attack. If at that time your number of warships is less than $x$, you lose. Otherwise, your number of warships will decrease by $x$. 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 $T$, the number of test cases. For each test case, the first line contains a positive integer $n$. The next $n$ lines each contain two numbers $t_i, x_i$, describing one wave of attack (note: they are not necessarily given in time order). It is guaranteed that for $i \ne j$, $t_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 $ans_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 $ans_2$ is the maximum number of attacks you can withstand.

Explanation/Hint

### Constraints This problem has $20$ test points, each worth $5$ points, with the following properties: Test points $1\sim 2$: $1 \le n \le 10$, $1 \le t_i \le 10$. Test points $3\sim 6$: $1 \le n \le 500$, $1 \le t_i \le 5000$. Test points $7\sim 8$: $1 \le n \le 5$. Test points $9\sim 10$: $1 \le n \le 5000$. Test points $11\sim 13$: It is guaranteed that the first line of the answer for each test case is always Defeat. Test points $14\sim 16$: It is guaranteed that the first line of the answer for each test case is always Victory. Test points $17\sim 20$: No additional constraints. For all data: $T = 10$, $1 \le n \le 10^5$, $1 \le t_i \le 10^6$, $1 \le x_i \le 10^{18}$, $\sum x_i \le 10^{18}$. Translated by ChatGPT 5