Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude Desktopsorting · two-pointers · pair-counting
The organizer’s problem statement is available at the official source link.
threshold pairs
Count gum pairs below the limit
A valid pair has two distinct types whose hardness sum is strictly smaller than K.
sorted x_i <= x_jx_i + x_j < Kcount valid partner range
- 1
Sort hardness
Sort hardness values. - 2
Move two pointers
For the smallest remaining value, move the right pointer until the sum is below K. - 3
Count valid pairs
Count the valid partners, then advance the left boundary without double-counting pairs.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 charsRun output
Run your code to see output.