#C8128. Optimal Event Planning
Optimal Event Planning
Optimal Event Planning
A company is planning its annual event and has gathered availability information from its employees. Each employee has provided a list of days they are available. Your task is to determine the day on which the event should be held so that the maximum number of employees can attend. In the event of a tie (i.e. multiple days having the same maximum attendance), you should choose the earliest day.
Let \(n\) be the number of employees and for each employee, the input provides the employee's name followed by the days (represented as positive integers) they are available. If \(l_d\) represents the number of employees available on day \(d\), you need to select the day \(d^*\) such that \(l_{d^*}\) is maximized and, in case of ties, \(d^* = \min\{ d : l_d = \max(l) \}\).
inputFormat
The input is read from stdin as follows:
\(n\) name_1 d_{1} d_{2} ... d_{k1} name_2 d_{1} d_{2} ... d_{k2} ... name_n d_{1} d_{2} ... d_{kn}
Where the first line contains an integer \(n\) representing the number of employees. Each of the following \(n\) lines contains an employee's name followed by one or more space-separated integers indicating the days they are available.
outputFormat
The output is printed to stdout and should contain:
maximum_attendance name_1 name_2 ... name_m
The first line is the maximum number of employees available on the chosen day. The subsequent lines list the names of the employees available on that day, sorted in lexicographical order.
## sample3
alice 1 2 3
bob 3 4 5
charlie 2 3
3
alice
bob
charlie
</p>