C++20 sections · 1024 units
Open in Course

Watermelon - Algorithm

How to solve

The algorithm is simple once you understand the insight. Here's the step-by-step approach:

1.1. Read the weight ww from input.

2.2. Check two conditions: is w>2w > 2? AND is ww even (meaning w%2==0w \% 2 == 0)?

3.3. If BOTH conditions are true, output YES.

If either fails, output NO. This runs in constant O(1)O(1) time since you're just checking two conditions. No loops, no arrays, just two boolean checks combined with AND. Simple problems often have simple solutions.