#C3114. Taco Balloon Game Rounds
Taco Balloon Game Rounds
Taco Balloon Game Rounds
In the Taco Balloon Game, you are presented with two types of balloons: red and blue. In each round, you select one balloon. The rule is that you can alternate selections between the two colors as much as possible. However, if one color runs out, you may still play an extra round using the remaining balloons. Your task is to determine the maximum number of rounds the game can last, given that you have r red balloons and b blue balloons.
Mathematically, let ( r ) and ( b ) denote the number of red and blue balloons, respectively. The maximum number of rounds is given by:
[ \text{rounds} = 2 \times \min(r, b) + \begin{cases} 1, & \text{if } |r - b| > 0 \ 0, & \text{otherwise} \end{cases} ]
If both r and b are zero, no rounds can be played. Note that even if only one type of balloon is available (i.e. one of r or b is zero), you can still play one round.
inputFormat
The input consists of a single line containing two non-negative integers r and b separated by a space. Here, r represents the number of red balloons and b represents the number of blue balloons.
outputFormat
Output a single integer representing the maximum number of rounds that can be played.## sample
3 5
7