Dsa
Greedy
Medium
Concert Seating Arrangement
You are organizing a concert with a fixed number of seats available. Each seat can accommodate one person, and attendees may prefer sitting together in groups. Given a list of groups and their sizes, you need to determine the maximum number of attendees that can be seated while respecting the groups' sizes.
Input Format:
- The first line contains two integers `s` (total number of seats) and `g` (number of groups).
- The next `g` lines each contain an integer representing the size of each group.
Output Format:
- Print the maximum number of attendees that can be seated without splitting any group.
Example:
Input:
10 4
2
3
5
1
Output:
10
Key concepts
greedysortingarrays
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