#C2326. Optimal Competition Day
Optimal Competition Day
Optimal Competition Day
You are organizing a competition and need to choose the day on which the most participants are available. You are given a total of \(D\) days and the availability schedule of \(P\) participants. Each participant's availability is represented by a list where the first number is the count \(k\) followed by \(k\) integers representing the days that the participant is available.
Your task is to determine the day \(d\) (with \(1 \le d \le D\)) that maximizes the number of participants who can attend. In case of a tie, choose the smallest day number.
The function to maximize is:
$$ \text{attendance}(d) = \sum_{i=1}^{P} \mathbb{1}_{\{d \in A_i\}}, $$where \(A_i\) is the set of days participant \(i\) is available.
inputFormat
The first line contains two integers \(D\) and \(P\), representing the total number of days and the number of participants respectively. Each of the following \(P\) lines begins with an integer \(k\) indicating the number of available days for that participant, followed by \(k\) integers representing the days they are available.
outputFormat
Output a single integer: the optimal day to host the competition.
## sample5 3
2 1 2
3 1 3 5
1 5
1