SnowflakeOA #33
Server Investment
Estimated EasyJudge-ready
Topics (AI-labelled)Bits & Math
Networks are independent. Each starts with n servers and funds money; selling a server yields sell, and upgrading a server costs upgrade. A sold server can no longer be upgraded. Find the maximum number of servers that can be upgraded in each network.
Input
The first line contains the number of networks q, followed by q lines of num_servers money sell upgrade. 1≤q≤100000, and all four values are in 1..10000.
Output
First output the number of networks, then output the maximum number of upgrades for each network.
Example 1
Input:
2
4 8 4 4
3 9 2 5
Output:
2
3 2
Example 2
Input:
1
1 1 1 10000
Output:
1
0
Example 3
Input:
1
10 10000 1 1
Output:
1
10
Example notes
The answers to the three public examples are, in order: 2 3 2; 1 0; 1 10. The examples were rechecked by independent enumeration, state search, or direct simulation.
Editorial
Loading solution…