Problem p03370 - Generation 3

Orig Description

Score : 200 points
Problem StatementAkaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
2 ≤ N ≤ 100
1 ≤ m_i ≤ 1000
m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
All values in input are integers.
InputInput is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
OutputPrint the maximum number of doughnuts that can be made under the condition.
Sample Input 13 1000
120
100
140
Sample Output 19
She has 1000 grams of Moto and can make three kinds of doughnuts. If she makes one doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360 grams of Moto. From the 640 grams of Moto that remains here, she can make additional six Doughnuts 2. This is how she can made a total of nine doughnuts, which is the maximum.
Sample Input 24 360
90
90
90
90
Sample Output 24
Making one doughnut for each of the four kinds consumes all of her Moto.
Sample Input 35 3000
150
130
150
130
110
Sample Output 326

Extracted Specification

An integer N (2 ≤ N ≤ 100), representing some quantity or size.
An integer X (1 ≤ X ≤ 10^5), representing another quantity.
A list of integers M of size N, where each integer is between 1 and 1000.

### Example Input:

```
3 1000
120
100
140
```

### Function Signature:
Write a function f(N, X, M) that takes in the input.
def f(N: int, X: int, M: List[int]):
    '''
    N: an integer
    X: an integer
    M: a list of integers
    '''

Test Case Generator

Sure! To generate test cases for the given problem, we need to ensure the generated values adhere to the constraints. Here's the test case generator:

```python
import random

def tcgen():
    # Number of kinds of doughnut
    N = random.randint(2, 100)
    
    # List of grams of Moto needed for each kind of doughnut
    m = [random.randint(1, 1000) for _ in range(N)]
    
    # Total grams of Moto available, ensuring the sum of m is less than or equal to X and X is in [sum(m), 10^5]
    sum_m = sum(m)
    X = random.randint(sum_m, min(10**5, sum_m + random.randint(0, 10**5 - sum_m)))
    
    return N, X, m

# Example of generating a test case
if __name__ == "__main__":
    for _ in range(5):  # Generate 5 test cases
        N, X, m = tcgen()
        print(f"{N} {X}")
        for grams in m:
            print(grams)
```

### Explanation:
1. **N**: The number of kinds of doughnuts, randomly chosen between 2 and 100.
2. **m**: A list of integers where each integer is the grams of Moto needed for each kind of doughnut. Each integer is randomly chosen between 1 and 1000.
3. **X**: The total grams of Moto available, ensuring it adheres to the constraints:
    - \( \text{sum}(m) \leq X \leq 10^5 \)
    - \( X \) is randomly chosen between the sum of the elements in \( m \) (to ensure at least one doughnut of each kind can be made) and the minimum of \( 10^5 \) or the sum of \( m \) plus a random value up to \( 10^5 - \text{sum}(m) \).

This ensures that the generated test cases are valid and adhere to the problem's constraints.

Extract Arguments

def extract_arguments(fh):
    N, X = map(int, fh.readline().strip().split())
    m = [int(fh.readline().strip()) for _ in range(N)]
    return N, X, m