아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Who Goes There?

시간 제한1초메모리 제한1024 MB

요약
사이트 정원과 학교별 등록 팀 수가 등록 순서대로 주어질 때, 팀 번호 순으로 차례로 배정하고 남은 자리는 등록 순서대로 학교에 배정하여 학교별 수용 팀 수를 구한다.
난이도

보통10점 중 4점

유형
시뮬레이션, 그리디, 구현
정답자
아직 제출이 없습니다

문제

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 nn (1≤n≤1001 \le n \le 100) and mm (1≤m≤1001 \le m \le 100), where nn is the capacity of the site and mm is the number of schools that wish to compete there.

Each of the next mm lines contains an integer tt (1≤t≤1001 \le t \le 100), which is the number of teams that a school has registered. The schools are listed in the order that they registered.

출력

Output mm 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.

예제1

  1. 예제 1

    입력
    20 5
    7
    5
    1
    6
    12
    
    예상 출력
    5
    5
    1
    5
    4