#K16071. Flower Planting Arrangement
Flower Planting Arrangement
Flower Planting Arrangement
You are given n slots and m different types of flowers. Your task is to determine whether it is possible to plant flowers in all n slots such that no two adjacent slots have the same type of flower.
The condition for a valid arrangement can be analyzed mathematically. In particular, one key observation is that if the number of slots satisfies \[ n \leq 2m - 1 \] then it is always possible to arrange them without adjacent duplicates (except for the cases where a single type is available for more than one slot). Otherwise, it may not be possible to satisfy the condition.
Decide if an arrangement exists and output YES
if it is possible, and NO
otherwise.
inputFormat
The input consists of a single line containing two space-separated integers n and m, where:
- n represents the number of slots.
- m represents the number of different types of flowers.
outputFormat
Output a single line with the word YES
if it is possible to plant the flowers under the given constraints, or NO
otherwise.
5 3
YES