#K8756. Balloon Arrangement
Balloon Arrangement
Balloon Arrangement
You are given two integers r
and b
representing the number of red and blue balloons respectively. Your task is to determine if it is possible to arrange all the balloons in a single row such that no two adjacent balloons are of the same color.
The arrangement is possible if and only if the difference between the counts of two colors is at most 1, i.e.,
Otherwise, an arrangement without identical adjacent balloons is not possible.
Note: The input consists of two space-separated integers provided from standard input, and your program should print a single line with either YES
or NO
on standard output based on the condition above.
inputFormat
The input consists of a single line containing two space-separated integers r
and b
:
r
- the number of red balloons.b
- the number of blue balloons.
You are to read the input from standard input.
outputFormat
Output a single line containing YES
if it is possible to arrange the balloons such that no two adjacent ones have the same color. Otherwise, output NO
. The output should be written to standard output.
3 3
YES