Problem p02948 - Generation 1

Orig Description

Score : 400 points
Problem StatementThere are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it.
You can take and complete at most one of these jobs in a day.
However, you cannot retake a job that you have already done.
Find the maximum total reward that you can earn no later than M days from today.
You can already start working today.
Constraints
All values in input are integers.
1 \leq N \leq 10^5
1 \leq M \leq 10^5
1 \leq A_i \leq 10^5
1 \leq B_i \leq 10^4
InputInput is given from Standard Input in the following format:
N M
A_1 B_1
A_2 B_2
\vdots
A_N B_N
OutputPrint the maximum total reward that you can earn no later than M days from today.
Sample Input 13 4
4 3
4 1
2 2
Sample Output 15
You can earn the total reward of 5 by taking the jobs as follows:
Take and complete the first job today. You will earn the reward of 3 after four days from today.
Take and complete the third job tomorrow. You will earn the reward of 2 after two days from tomorrow, that is, after three days from today.
Sample Input 25 3
1 2
1 3
1 4
2 1
2 3
Sample Output 210
Sample Input 31 1
2 1
Sample Output 30

Extracted Specification

An integer N (1 ≤ N ≤ 10^5), representing some quantity or size.
An integer M (1 ≤ M ≤ 10^5), representing some other quantity or size.
A list of tuples of size N, where each tuple consists of two integers (A_i, B_i), with 1 ≤ A_i ≤ 10^5 and 1 ≤ B_i ≤ 10^4.

### Example Input:

```
3 4
4 3
4 1
2 2
```

### Function Signature:
Write a function f(N, M, inputs) that takes in the input.
def f(N: int, M: int, inputs: List[Tuple[int, int]]):
    '''
    N: an integer
    M: an integer
    inputs: a list of tuples, where each tuple consists of two integers
    '''

Test Case Generator

Sure! To generate test cases for this problem, we need to generate values for \(N\), \(M\), and lists of \(A_i\) and \(B_i\) according to the given constraints:

- \(1 \leq N \leq 10^5\)
- \(1 \leq M \leq 10^5\)
- \(1 \leq A_i \leq 10^5\)
- \(1 \leq B_i \leq 10^4\)

Here's a Python function that generates such test cases:

```python
import random

def tcgen():
    N = random.randint(1, 10**5)
    M = random.randint(1, 10**5)
    
    A = [random.randint(1, 10**5) for _ in range(N)]
    B = [random.randint(1, 10**4) for _ in range(N)]
    
    return N, M, list(zip(A, B))

# Example usage:
N, M, jobs = tcgen()
print(N, M)
for job in jobs:
    print(job[0], job[1])
```

### Explanation:
1. **N**: Randomly generate the number of jobs (1 to 100,000).
2. **M**: Randomly generate the maximum days allowed (1 to 100,000).
3. **A**: Generate a list of \(N\) integers, each representing the number of days after which a job's reward is received (1 to 100,000).
4. **B**: Generate a list of \(N\) integers, each representing the reward for completing the job (1 to 10,000).

The function `tcgen()` returns \(N\), \(M\), and a list of tuples where each tuple contains \(A_i\) and \(B_i\). The example usage shows how to print the generated test case in the required format.

This will help in testing various edge cases and typical cases for the given problem.

Extract Arguments

def extract_arguments(fh):
    N, M = map(int, fh.readline().strip().split())
    jobs = []
    for _ in range(N):
        A, B = map(int, fh.readline().strip().split())
        jobs.append((A, B))
    return N, M, jobs