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

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

Greedy Scheduler

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

요약
대기 중인 손님을 가장 번호가 작은 빈 계산원에게 차례로 배정하고, 각 손님을 담당하는 계산원 번호를 출력한다.
난이도

보통10점 중 4점

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

문제

A store has n cashiers numbered sequentially from 1 to n, with c customers in a queue. A customer at the front of the queue is constantly assigned to the first unoccupied cashier, (i.e., if more than one cashier is unoccupied select the cashier with the smallest number). The ith customer’s shopping cart takes ti seconds to process.

Find which cashier will process each customer’s shopping cart.

입력

The first line of input will contain a single integer m that indicates the number datasets to follow. Each dataset is comprised of two lines. The first line of input contains two space-separated integers n and c (1 ≤ n ≤ c ≤ 1000). The second line of input contains c space-separated integers t1, . . . , tc, representing the length of time required to handle that customer.

출력

For each dataset print, on a single line c integers separated by one space, where each integer is the cashier number that handles that customer.

예제1

  1. 예제 1

    입력
    1
    3 10
    406 424 87 888 871 915 516 81 275 578
    
    예상 출력
    1 2 3 3 1 2 3 1 2 1