← CSES Better

Gift Coupons

INOI · 2006 · Indian National Olympiad in Informatics · INOI0601

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

arrays · three-sum · distinctness

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

three book sum

Find three distinct books matching the coupon value

Choose three different catalogue entries whose prices sum exactly to the coupon value.

State table
Book indicesDistinctnessCoupon condition
i < j < kthree different booksprice_i + price_j + price_k = coupon value
  1. 1

    Choose distinct entries

    Select three different book indices i, j, and k.
  2. 2

    Match the coupon

    Their three prices must sum exactly to M.
  3. 3

    Return a valid triple

    Report any matching triple, or the no-solution result when none exists.
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.