You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: