atcoder#AGC018B. [AGC018B] Sports Festival
[AGC018B] Sports Festival
Score : points
Problem Statement
Takahashi is hosting an sports meet. There are people who will participate. These people are conveniently numbered through . Also, there are options of sports for this event. These sports are numbered through . Among these options, Takahashi will select one or more sports (possibly all) to be played in the event.
Takahashi knows that Person 's -th favorite sport is Sport . Each person will only participate in his/her most favorite sport among the ones that are actually played in the event, and will not participate in the other sports.
Takahashi is worried that one of the sports will attract too many people. Therefore, he would like to carefully select sports to be played so that the number of the participants in the sport with the largest number of participants is minimized. Find the minimum possible number of the participants in the sport with the largest number of participants.
Constraints
- , , , is a permutation of the integers from to .
Input
Input is given from Standard Input in the following format:
Output
Print the minimum possible number of the participants in the sport with the largest number of participants.
4 5
5 1 3 4 2
2 5 3 1 4
2 3 1 4 5
2 5 4 3 1
2
Assume that Sports , and are selected to be played. In this case, Person will participate in Sport , Person in Sport , Person in Sport and Person in Sport . Here, the sport with the largest number of participants is Sport , with two participants. There is no way to reduce the number of participants in the sport with the largest number of participants to . Therefore, the answer is .
3 3
2 1 3
2 1 3
2 1 3
3
Since all the people have the same taste in sports, there will be a sport with three participants, no matter what sports are selected. Therefore, the answer is .