The school year is starting soon, so Yunji wants to make some friends through his school's Discord server. In the server, there are
Unfortunately, everyone from Yunji's school dislikes him everyone has important things to do other than Discord, so for every minute he is in the
Yunji has
The total quality is the sum of the qualities of every call
Help Yunji maximize the total quality.
Input Specification
The first line will contain
The second line will contain
Output Specification
Output the maximum total quality that Yunji can achieve through strategically hopping between calls.
Constraints
Subtask 1 [5%]
Subtask 2 [15%]
Subtask 3 [80%]
No additional constraints.
Sample Input 1
2 2
9 3
Sample Output 1
17
Explanation for Sample 1
Yunji can spend all his time in the first call: if he does there will be 9 participants in the call in the first minute, and 8 participants in the second minute. The quality of this call would be
Sample Input 2
2 3
5 6
Sample Output 2
16
Explanation for Sample 2
Yunji can spend the first minute in call
Comments
My code seems to be failing a test case and I can't figure out why, can someone take a look?
There cannot be negative participants in a call, so make sure you're not adding negative numbers to your sum.
Oh I see, thanks!
Is there any special cases in this problem? The third test case of every batch gives me a WA.
Your sum may be
so the int type overflows.