C++20 sections · 1024 units
Open in Course

Xenia - Algorithm

Breaking it down

Here's your approach:

1.1. Read nn (number of houses) and mm (number of tasks).

2.2. Create a vector to store the mm house numbers you need to visit.

3.3. Initialize your current position to 11 and total time to 00.

4.4. Loop through each task in the vector.

5.5. For each target house, compute the clockwise distance using the formula from the previous unit.

6.6. Add this distance to your total time.

7.7. Update your current position to the target house.

8.8. Output the total time.