← CSES Better

The Rajah's Wrestlers

INOI · 2004 · Indian National Olympiad in Informatics · INOI0402

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

tournament · ordering · optimization

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

tournament ordering

Minimize coins by choosing the presentation order

Every pair fights once. A wins when sA + rA*sB exceeds sB + rB*sA. A wrestler earns one coin per win, plus one for each defeated wrestler presented earlier.

State table
MatchupA indexB index
A vs BsA + rA * sBsB + rB * sA
presentation orderwins + earlier defeated wrestlersmaximize/compute coin awards
  1. 1

    Resolve each match

    For wrestlers A and B, compare sA + rA*sB with sB + rB*sA.
  2. 2

    Count awards for an order

    Each win earns one coin; an earlier presentation of a defeated wrestler adds one more coin.
  3. 3

    Minimize the total

    Choose a presentation sequence that minimizes the total coins awarded.
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.