IBMOA #40
Get Optimal String Length
估计中等可在线判题
Using at most countA A's and countB B's, with at most maxA consecutive A's and at most maxB consecutive B's, find the maximum length of a string you can construct. You need not use all the characters; a maximum run length of 0 for a letter means that letter cannot be used.
输入格式
One line containing countA countB maxA maxB, all four integers in 0..10^6.
输出格式
Output one integer, the answer.
样例 1
输入:
5 1 2 1
输出:
5
样例 2
输入:
3 4 0 2
输出:
2
样例 3
输入:
0 0 0 0
输出:
0
样例说明
The examples give 5, 2 and 0 respectively. In the first example, AABAA can be constructed.