/ StarOI / 题库 /

Bob and Study

Bob and Study

Bob and Study

Description

In the elite class of Nanjing University, students have a lot of knowledge to learn every day. As a lazy student, Bob does not always want to study.

Suppose the happiness of Bob is initially \(h_0\). For the next \(n\) days, Bob will wake up from a sweet dream or a nightmare and get \(a_i\) happiness points at the beginning of day \(i\) (note that \(a_i\) might be negative). Then on that day, Bob can choose to study, which will cost him \(b_i\) happiness points, or to play video games, which does no change to his happiness.

Bob does not want to fall behind other hardworking students, but he also wants to be happy for all of \(n\) days. In other words, Bob want to study as much as he could, but his happiness must be positive (\(h_i>0\)) at the end of each day. To arrange his school life, Bob wants to know:

  • The maximum number of days he can spent studying, and
  • His maximum happiness in the end (if he studies for the maximum number of days).

Bob asked a 'dalao' in class to help him and 'dalao' solved the problem easily using dynamic programming method. Bob realized that, when \(n\) grows larger and larger, the DP method would lose the balance of space and time and may get TLE/MLE/RTE verdict. Since he knows that you have learned the greedy algorithm very well, he turns to you to find another solution. (已生成新数据,NJUOJ上的数据范围将会不同。)

Input

There are multiple test cases. The first line of input contains an integer \(T\), indicating the number of test cases.

For each test case, the first line contains two integer \(n\) and \(h_0\). The following two lines each contains \(n\) integers, namely \(a_1 \ldots a_n\) and \(b_1 \ldots b_n\).

All data are randomly generated. It is guaranteed that for each test case, we have \(n \leq 2 \times 10^4\), \(-10^9 \leq h, a_i \leq 10^9\), \(0 \leq b_i \leq 10^9\), and Bob will not be unhappy at the beginning of day 1. The sum of \(n\) does not exceed \(10^5\).

Output

For each test case, output one line containing two integers.

The first integer is the maximum number of days that Bob can spent studying. The second integer is the maximum happiness Bob could obtain in the end if he would study for the maximum number of days.

However, if Bob will be unhappy even if he doesn't study at all, you shall output "Bob will be unhappy!" (without quotation marks) instead.

Sample Case

Input

3
3 1
0 0 -1
1 1 1
3 0
1 1 1
1 1 1
6 0
2 3 3 3 3 3
1 1 4 5 1 4

Output

Bob will be unhappy!
2 1
5 6

Explanation

For the second case, Bob can study for at most 2 days (2 and 3), and his happiness would be at most 1 if he studies for 2 days.

For the third case, Bob will be unhappy on day 3 anyway.

信息

难度
9
分类
贪心 点击显示
标签
(无)
递交数
13
已通过
3
通过率
23%
上传者