In a taxi company n n taxis in a queue and 4 n 4n people are in another queue. People in…
- User
In a taxi company n n taxis in a queue and 4 n 4n people are in another queue. People in line get into the first taxi in order, and any taxi that fills up (4 people get into it) starts immediately.
Each taxi has two parts. The front seat that can take exactly one passenger and the back seats that can take exactly 3 passengers. It should also be noted that passengers can get on or off the rear seats only from the right door.
The city has a main street and 101 stations with numbers 0 to 100 are located on the street. Station 0 is the taxi company, and each person's destination is one of stations 1 to 100. Each taxi starts from station 0 and goes to station 100 and stops whenever it reaches the destination of one of the passengers. Since only the door on the right side can be opened, when someone from the back seats wants to get off at his destination, the people on his right side also have to get off, which causes them discomfort.
More precisely, the level of discomfort of people in a taxi is equal to the number of times they got off at a station other than their destination. Note that a person may be upset several times and each time the amount of discomfort increases.
When boarding, each person either sits in the front seat or enters the back seats through the right door and sits in the leftmost empty seat. Now, the taxi company wants you, knowing the destinations of the 4 passengers of each taxi, to determine which person should sit in the front in each taxi so that the total amount of people's discomfort is minimized.
For more understanding, refer to the example descriptions.
input In the first line of the input n n number of taxis come and go 4 x n 4xn next line d i d i the person's destination i i'm coming 1 ≤ n ≤ 20 , 000 1≤n≤20,000 1 ≤ d i ≤ 100 1≤d i ≤100
output in line i The minimum total inconvenience of taxi people i i will be output.
Example Sample entry 1 3 1 1 1 1 2 1 1 2 3 1 4 2 Plain text Sample output 1 0 0 1 Plain text In the first taxi, 4 people board with the same destination, and no one gets upset in all boarding situations.
In the second taxi, people are supposed to board with destinations 2 and 1 and 1 and 2 respectively, and if the first three people sit in the back and the last person sits in the front, then there will be no inconvenience. Because at station 1, the last two people who boarded will get off, and at station 2, two more people will get off.
In the third taxi, if the person with destination 1 sits in the front and people with destinations 3, 4, and 2 ride in the back, respectively, the total amount of discomfort is 1, and it can be verified that there is no condition with 0 discomfort. First, at station 1, the person with destination 1, who is sitting in front, gets off. At station 2, person 2 also gets off without causing inconvenience. But at station 3, because person 4 is sitting behind person 3, he is closer to the door, and he has to get off and get on again for person 3, and there is an inconvenience. c++
- Assistant