Eleven problems whose order you write yourself. Before coding, write the rule as a ladder in words: first by …; if equal, by …. Then the comparator is a transcription.
- Student Ranking: the lesson's ranking with the fields renamed — score down,
penalty up, name up. 5·10⁵ records:
constreferences in the comparator. - Stable Queue: priority down, and arrival order among equals — the index is the second key. Names repeat, so never compare by name.
- Рестораны Таджикистана: city A to Z, then the score down; print the restaurants' input numbers, so each record carries its index.
- Calendar Dates: year, month, day — three
intfields, three rungs. - Event Priorities: the type word becomes a number (
END0,QUERY1,START2) when the record is read; then time, type, id. - Top Priority Event: only the first element after sorting is wanted. Sort
and print
v[0], or run the comparator in a single maximum loop. - Covering Intervals: keep only the intervals that contain x, as
{length, index}pairs; the default pair order is the one wanted. Bounds are 10¹⁸:long long. - Exact Ratio Order: compare p₁/q₁ with p₂/q₂ without division:
p1 * q2 < p2 * q1(q is positive). The products reach 10¹⁸, which fits along long; the id breaks ties. - Nested Birthday: month, then day, then name — the year is read and ignored.
- Weighted Edges: weight, then the pair
{min(u, v), max(u, v)}, then id. A pair compared with<makes one rung of the ladder. - Stable Multi-Key Sort: k keys per record (k up to 5) — read them into a
vector<int>; two vectors compare with<like pairs, position by position. Then{keys, id}pairs sort in exactly the order asked.