Problem p01996 - Generation 1

Orig Description

A: Test
Problem
  In a classroom with $N$ seats in a straight line, $M$ students are going to take a test.
  Each seat is numbered from $1 \dots N$, and one student can sit in one seat.
  At this moment, each student sits in seat $A_1, \dots, A_M$.
  To start the test, the following condition must be satisfied.
  
There must be at least one student in every seat from $1 \dots M$.
  Therefore, we decided to repeat the following operation until the condition is satisfied.
  
Move the student who is sitting at the rearmost position to the frontmost available seat.
  Find the number of operations required to satisfy the condition.
Constraints
All input values are integers.
$1 \leq N \leq 1000$
$1 \leq M \leq N$
$1 \leq A_i \leq N$
If $1 \leq i < j \leq M$, then $A_i < A_j$
Input Format
 The input is given in the following format. 
  $N\ M$
  $A_1 \dots A_M$
Output
Output the number of operations required to satisfy the condition, followed by a newline character. 
Sample
Sample Input 1
6 4
1 4 5 6
Sample Output 1
2
Sample Input 2
10 3
1 2 3
Sample Output 2
0

Extracted Specification

An integer N (1 ≤ N ≤ 1000), representing some quantity or size.
An integer M (1 ≤ M ≤ N), representing some quantity or size.
A list of M integers A, where each integer is between 1 and N. The list is in strictly increasing order.

### Example Input:

```
6 4
1 4 5 6
```

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

Test Case Generator

Sure! Here is the test case generator for the problem statement you provided:

```python
import random

def tcgen():
    N = random.randint(1, 1000)
    M = random.randint(1, N)
    
    # Generate a list of M unique integers within the range 1 to N
    A = sorted(random.sample(range(1, N + 1), M))
    
    return N, M, A

# Example usage:
N, M, A = tcgen()
print(N, M)
print(" ".join(map(str, A)))
```

This generator function follows the constraints provided:
1. `N` is a random integer between 1 and 1000.
2. `M` is a random integer between 1 and `N`.
3. `A` is a sorted list of `M` unique integers between 1 and `N`, ensuring that the seats are in ascending order.

Here's an example of the output from running the generator:

```
Example Output:
7 3
1 5 7
```

This output indicates:
- There are 7 seats in total.
- There are 3 students sitting at positions 1, 5, and 7.

This test case generator should be helpful for creating multiple random test cases for the problem.

Extract Arguments

def extract_arguments(fh):
    N, M = map(int, fh.readline().strip().split())
    A = list(map(int, fh.readline().strip().split()))
    return N, M, A

# if __name__ == "__main__":
#     input_path = sys.argv[1]
#     with open(input_path, 'r') as fh: 
#         N, M, A = extract_arguments(fh)
#         f(N, M, A)