Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UVa 13177 - Orchestral scores #2

Open
Veercodeprog opened this issue Aug 23, 2024 · 0 comments
Open

UVa 13177 - Orchestral scores #2

Veercodeprog opened this issue Aug 23, 2024 · 0 comments

Comments

@Veercodeprog
Copy link
Owner

https://vjudge.net/problem/UVA-13177
In a modest orchestra, a big part of the budget goes when
buying scores. If each musician had their own copy, the number could go over 100.
Fortunately, musicians that are playing the same instrument can sit together and share a music stand. That’s a major
saving, but if it is used too much, it can provoke an ugly effect
in the concert hall. After all, seeing a lot of musicians in a
crowd behind a stand is not very esthetic.
The section of economic affairs of the orchestra has informed us of the number of scores we can buy for the next
concert. Keeping in mind the number of musicians that play each of the instruments, which stand will
be the most concurred?
For example, if we have 8 violins, 5 violas, 5 cellos and 2 contrabasses and there is enough budget for
6 scores, we can buy two stands for violins, two for violas, one for cellos and a final one for contrabasses.
In this case, the most crowded stand will be the one from the cellos, with 5 musicians behind it.
Input
Input will have several test cases, each of them composed by two lines. The first line contains two
integers, p and n, with the number of scores we are allowed to buy (up to 200,000) and the number
of different instruments that are part of the orchestra (up to 100,000). It is guaranteed that it will be
possible to buy at least one stand for each type of instrument.
The second line contains n positive numbers indicating the amount of musicians that are part of
the orchestra for each of the instruments (up to 1,000).
Output
For each test case, write a single integer indicating the number of musicians that will share the most
crowded stand, always meeting the orchestra and budget restrictions. Don’t forget that the objective
is to minimize the amount of people in the most crowded stand.
Sample Input
4 4
8 5 5 2
6 4
8 5 5 2
7 4
8 5 5 2
Sample Output
8
5
4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant