Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude Desktopsorting · greedy · optimization
The organizer’s problem statement is available at the official source link.
price sweep
Revenue changes only at customer budgets
At price p, customers with budget at least p buy the app. Revenue is p times that eligible-customer count.
| Candidate price p | Eligible customers | Revenue |
|---|---|---|
| p | count(budget >= p) | p * count(budget >= p) |
| all candidate p | customers who can afford p | maximum revenue |
- 1
Sort budgets
Sort the budgets from low to high. - 2
Try candidate prices
For each distinct candidate price, count customers whose budgets still cover it. - 3
Maximize revenue
Keep the largest price-times-count revenue.
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.