PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000304. Thành lập hội đồng học sinh (Student Councils)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Thành lập hội đồng học sinh (Student Councils)
Student Councils
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
There are groups with students in group i. Each council must have exactly students from distinct groups. A student may belong to at most one council or remain unused. Maximize the number of councils. This PHOJ adaptation uses locally defined limits.
Input
First line: , in this order. Second line: integers .
Output
Print the maximum number of councils.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; .
Examples
Input 1
2 3
4 2 1
Output 1
3
Explanation
Use groups 1 and 2 twice, then groups 1 and 3 once. Seven students cannot fill four councils.