#P8838. [传智杯 #3 决赛] 面试
[传智杯 #3 决赛] 面试
Background
disangan233 and disangan333 went to an interview. The interviewer gave them a problem. Can you, as a helpful person, assist them?
Problem Description
There are servers. Server can process data of size at most .
Next, there will be commands . Command means sending data of size , and you need to assign an idle server to it.
Please compute a sequence indicating that the data of command is assigned to server , and is lexicographically smallest. If it is impossible to assign, output "-1".
For all testdata, , .
Input Format
The input consists of lines.
Line contains two positive integers .
Line contains positive integers , where indicates the maximum data size that server can process.
Line contains positive integers , where indicates command .
Output Format
Output one line containing positive integers , or output "-1".
6 6
1 9 1 9 8 1
1 1 4 5 1 4
1 3 2 4 6 5
Hint
Sample Explanation
Command is assigned to server .
Command is assigned to server .
Command is assigned to server .
Command is assigned to server .
Command is assigned to server .
Command is assigned to server .
Translated by ChatGPT 5