Bus Seating
시간 제한3초메모리 제한2048 MB
승객이 탈 때마다 (C에서 행 거리를 뺀 값)을 그 행의 기존 승객 수만큼 절반으로 나눈 값이 최대인 행을 고르고, 동점이면 번호가 작은 행을 택한다. 모든 승객의 좌석 행을 출력한다.
문제
A bus has rows numbered through with seats in each row, and there will be people entering the bus. Each person has a favorite row, and they will derive utility from being able to sit in that row. People prefer to sit closer to their favorite row, so if a person's favorite row is , and they sit in row , then that person will normally derive utility for sitting in it.
However, people are also introverts. For each person already sitting in a given row, the utility the person would derive gets halved. Formally, if people are already sitting in row and the person's favorite row is , then the person would derive utility for sitting in row . Each seat can accommodate exactly one person, so if all seats in a row are occupied, then the person cannot sit in that row.
Can you determine where everyone will sit, if every person is trying to maximize their personal utility at the time they decide where to sit? If the row that maximizes the personal utility is not uniquely determined, the person will pick, among all such rows, the row with the smallest number. People do not change rows after sitting down.
입력
The first line of input contains four integers , and (, , and ) --- the number of rows in the bus, the number of seats in each row, the number of people entering the bus, and each person's utility of sitting in their favorite row, respectively.
The next line contains integers () --- is person 's favorite row. People sit down in the order specified in the input.
출력
Output one line containing integers () --- being the row in which person will sit.
힌트
In the first sample, here is what the utilities look like for every person:
- The utilities for a person with preference are so they choose row .
- The utilities for a person with preference now are so they choose row .
- The utilities for a person with preference now are so they choose row .
- The utilities for a person with preference now are so they choose row .
- The utilities for a person with preference now are so they choose row .
- The utilities for a person with preference now are . Since row is full, they choose row .