#P17380. [PacNW 2025] Bus Seating
[PacNW 2025] Bus Seating
Problem Description
A bus has rows, numbered through , with seats in each row. A total of people will enter the bus. Each person has a favorite row and receives utility from sitting in that row. If a person's favorite row is and they sit in row , their utility before accounting for other passengers is .
However, the passengers are introverts. Each person already sitting in a row halves the utility a new passenger would receive from that row. Formally, if people are already sitting in row , then a passenger whose favorite row is receives
utility by sitting in row . A row with all seats occupied cannot be selected.
Each person chooses a row that maximizes their utility at the moment they sit down. If several rows give the same maximum utility, they choose the row with the smallest number. Nobody changes rows after sitting down. Determine where every passenger sits.
Input Format
The first line contains four integers , , , and (, , and ): the number of rows, the number of seats per row, the number of passengers, and the utility of sitting in one's favorite row.
The second line contains integers (), where is passenger 's favorite row. Passengers sit down in input order.
Output Format
Output one line containing integers , where is the row chosen by passenger .
3 2 6 4
3 2 3 2 2 1
3 2 1 2 1 3
2 5 8 1000000000
2 2 2 2 2 2 2 2
2 1 2 1 2 1 2 1
Hint
In the first sample, the utilities available to each passenger are as follows:
-
A passenger who prefers row sees utilities and chooses row .
-
A passenger who prefers row sees utilities and chooses row .
-
A passenger who prefers row sees utilities and chooses row .
-
A passenger who prefers row sees utilities and chooses row .
-
A passenger who prefers row sees utilities and chooses row .
-
A passenger who prefers row sees utilities . Row is full, so they choose row .