#K44637. Net Savings
Net Savings
Net Savings
You are given a number of test cases. For each test case, you have a list of creatures. Each creature has a name, total income, and total expenses. The net savings for a creature is defined as \( \text{income} - \text{expenses} \).
Your task is to determine which creature has the maximum net savings for each test case. In the event of a tie, output the creature whose name is lexicographically larger. If no creature has positive net savings (i.e. \( \leq 0 \)), output No savings
.
inputFormat
The first line contains an integer \( T \) representing the number of test cases. For each test case:
- The first line contains an integer \( N \), the number of creatures.
- The following \( N \) lines each contain a string and two integers separated by spaces: the creature's name, total income, and total expenses.
outputFormat
For each test case, output a single line containing the name of the creature with the maximum net savings if that value is greater than 0. Otherwise, print No savings
.
2
3
Dragon 5000 2000
Unicorn 3000 2500
Phoenix 2000 2500
2
Gryphon 4000 4000
Mermaid 5000 5000
Dragon
No savings
</p>