C++20 sections · 1024 units
Open in Course

Next Round - Algorithm

Breaking down the solution

Here's your approach:

1.1. Read nn (total contestants) and kk (cutoff position).

2.2. Read all nn scores into an array.

3.3. Store the kk-th score as your threshold (careful: arrays are 0-indexed, so it's scores[k-1]).

4.4. Initialize a counter to zero.

5.5. Loop through each score and check: is it positive AND at least the threshold?

6.6. If both conditions are true, increment your counter. The approach is using && (AND) to combine conditions: score > 0 && score >= threshold. Both must be true for a contestant to advance.