← CSES Better

Covering

ZCO · 2015 · Zonal Computing Olympiad · ZCO15003

Open official problem ↗
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

intervals · greedy · covering

The organizer’s problem statement is available at the official source link.

interval hitting

Place a point at the earliest finishing interval

A chosen integer covers an interval when it lies inside it; choosing the right endpoint covers as many upcoming intervals as possible.

input interval 1
0–3
input interval 2
1–4
chosen cover point
2–5
  1. 1

    Sort by right edge

    Sort intervals by their right endpoints.
  2. 2

    Place the next point

    When the next interval is not hit by the last chosen point, place a new point at its right endpoint.
  3. 3

    Cover all intervals

    Continue until every interval has a selected point.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 chars

Run output

Run your code to see output.