cswork / OA打开练习工作台

SnowflakeOA #33

Server Investment

估计简单可在线判题

考点(AI 标注)位运算

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.

输入格式

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.

输出格式

First output the number of networks, then output the maximum number of upgrades for each network.

样例 1

输入:

2
4 8 4 4
3 9 2 5

输出:

2
3 2

样例 2

输入:

1
1 1 1 10000

输出:

1
0

样例 3

输入:

1
10 10000 1 1

输出:

1
10

样例说明

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.