#SGM0000021. Phân phòng khách sạn (Hotel Queries)
Phân phòng khách sạn (Hotel Queries)
Hotel Queries
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
There are hotels numbered from to . Hotel currently has free rooms. There are groups arriving in order, and group requires rooms in one hotel.
For each group, choose the smallest hotel index whose number of free rooms is at least . Then decrease that hotel's free-room count by . If no hotel can accommodate the group, it is not assigned.
Input
The first line contains .
The second line contains .
The third line contains .
Output
Print integers. The -th integer is the selected hotel index, or if the group cannot be assigned.
Subtasks
- Subtask 1 — 20%: .
- Subtask 2 — 30%: .
- Subtask 3 — 50%: , .
Examples
Input
8 5
3 2 4 1 5 5 2 6
4 4 7 1 1
Output
3 5 0 1 1
Explanation
The sample is processed in order; every printed item/line corresponds to an operation that requires output.