Жишээ тэстүүд

Оролт
3 2
1 1
1 4
2 2
Гаралт
3
Оролт
2 1
3 2
4 0
Гаралт
-1
Оролт
5 2
2 10
2 10
1 1
3 1
3 1
Гаралт
12

Тэмдэглэл

Consider the first test case. At the time when Manao joins the tournament, there are three fighters. The first of them has 1 tournament point and the victory against him requires 1 unit of effort. The second contestant also has 1 tournament point, but Manao needs 4 units of effort to defeat him. The third contestant has 2 points and victory against him costs Manao 2 units of effort. Manao's goal is top be in top 2. The optimal decision is to win against fighters 1 and 3, after which Manao, fighter 2, and fighter 3 will all have 2 points. Manao will rank better than fighter 3 and worse than fighter 2, thus finishing in second place.

Consider the second test case. Even if Manao wins against both opponents, he will still rank third.