Question bank › Greedy
Dsa Greedy Hard

Concert Ticket Allocation

You are in charge of distributing concert tickets to fans who are willing to pay up to a specific price for each ticket. Each fan can specify their maximum price limit, and you have a limited number of tickets with a fixed price. Given the list of fans' maximum price limits and your ticket price, determine the maximum number of fans that can receive a ticket. You will read the ticket price and a list of maximum price limits of fans. Output the total number of fans that can get tickets. Input Format: The first line contains an integer P (1 <= P <= 10^5) - the price of a ticket. The second line contains an integer F (1 <= F <= 10^5) - the number of fans. The third line contains F space-separated integers representing the maximum price limits of fans. Output Format: Print a single integer representing the maximum number of fans that can receive tickets. Example: Input: 30 5 20 35 40 50 25 Output: 3

Key concepts

greedysortingpriority

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.