Orig Description
Activity Selection Problem
There are $n$ activities with start times $\{s_i\}$ and finish times $\{t_i\}$. Assuming that a person can only work on a single activity at a time, find the maximum number of activities that can be performed by a single person.
Input
$n$
$s_1$ $t_1$
$s_2$ $t_2$
:
$s_n$ $t_n$
The first line consists of the integer $n$. In the following $n$ lines, the start time $s_i$ and the finish time $t_i$ of the activity $i$ are given.
Output
Print the maximum number of activities in a line.
Constraints
$1 \le n \le 10^5$
$1 \le s_i \lt t_i \le 10^9 (1 \le i \le n)$
Sample Input 1
5
1 2
3 9
3 5
5 9
6 8
Sample Output 1
3
Sample Input 2
3
1 5
3 4
2 5
Sample Output 2
1
Sample Input 3
3
1 2
2 3
3 4
Sample Output 3
2
Extracted Specification
An integer n (1 ≤ n ≤ 10^5), representing some quantity or size.
A list of tuples of integers (s, t) of size n, where 1 ≤ s < t ≤ 10^9.
### Example Input:
```
5
1 2
3 9
3 5
5 9
6 8
```
### Function Signature:
Write a function f(inputs) that takes in the input.
def f(inputs: List[Tuple[int, int]]):
'''
inputs: a list of tuples of integers
'''
Test Case Generator
Sure! Below is a test case generator for the Activity Selection Problem as described in your problem statement.
```python
import random
def tcgen():
# Generate a random number of activities
n = random.randint(1, 10**5)
activities = []
for _ in range(n):
# Generate random start and finish times such that 1 <= s_i < t_i <= 10^9
s = random.randint(1, 10**9 - 1)
t = random.randint(s + 1, 10**9)
activities.append((s, t))
# Sort activities by start time for more realistic test cases (optional)
activities.sort()
# Format the output
output = f"{n}\n" + "\n".join(f"{s} {t}" for s, t in activities)
return output
# Example usage
print(tcgen())
```
This generator creates a random number of activities `n` within the specified range, and for each activity, it generates random start and finish times that satisfy the constraint `1 ≤ s_i < t_i ≤ 10^9`. The activities are optionally sorted by start time to create more realistic scenarios. The output is formatted as specified in the problem statement.
You can run this generator multiple times to create various test cases for the Activity Selection Problem.
Extract Arguments
def extract_arguments(fh):
n = int(fh.readline().strip())
activities = []
for _ in range(n):
s, t = map(int, fh.readline().strip().split())
activities.append((s, t))
return n, activities
# if __name__ == "__main__":
# input_path = sys.argv[1]
# with open(input_path, 'r') as fh:
# n, activities = extract_arguments(fh)
# f(n, activities)