Who Goes There?
시간 제한1초메모리 제한1024 MB
사이트 정원과 학교별 등록 팀 수가 등록 순서대로 주어질 때, 팀 번호 순으로 차례로 배정하고 남은 자리는 등록 순서대로 학교에 배정하여 학교별 수용 팀 수를 구한다.
문제
What happens when more teams want to go to an ICPC regional site than the site has capacity for? Who goes there?
One possible policy is the following: Every school is allowed to register as many teams as they wish. Accept every school's first team, then accept every school's second team (for schools with more than one team), then third, and so on, until all teams are accepted, or there isn't enough capacity for the next wave. Then, if there are extra spots available, the spots are given to schools, one by one, in the order that the schools registered.
Given the capacity of a site, the number of teams registered by each school and the order that they registered, determine how many teams from each school are accepted.
입력
The first line of input contains two integers () and (), where is the capacity of the site and is the number of schools that wish to compete there.
Each of the next lines contains an integer (), which is the number of teams that a school has registered. The schools are listed in the order that they registered.
출력
Output lines, one for each school. Each line must contain a single integer indicating the number of teams accepted from that school. Output them in the same order as they appear in the input.