C++20 sections · 1024 units
Open in Course

George - Algorithm

Breaking it down

Here's your approach:

1.1. Read nn (number of rooms).

2.2. For each room, read a pair (occupancy, capacity).

3.3. Initialize a counter to 00.

4.4. Loop through each room.

5.5. Check if

This solution uses a simple loop with a condition. You process each pair independently. The order doesn't matter because you're just counting rooms that meet the criteria. Each step should be clear and testable. Before coding, trace through with a small example to verify the logic. Think about edge cases: empty input, single element, maximum values. Make sure your algorithm handles them correctly.