| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3 초 | 2048 MB | 18 | 3 | 3 | 18.750% |
At TU Delft, more and more courses are going back to on-campus lectures. So, naturally, it becomes more difficult to effectively schedule which lecturer can have which lecture hall. They asked you, an algorithm expert, for help on this sub-problem:
There are $n$ lectures that happen at the same time, numbered 1ドル$ to $n$. In the $i$th course, $x_i$ students will attend the lecture on-campus. The lectures are ordered by friendliness of the professor who gives the lecture, with the friendliest lecturer (we all know who that is) giving lecture 1ドル$.
There are $m$ lecture halls. The lecture halls are numbered from 1ドル$ to $m$ and the $j$th lecture hall has capacity $c_j$. The list of $m$ lecture halls is ranked on "niceness", with the nicest lecture hall on top.
Write a program that reads in the lectures and lecture halls and makes a valid assignment of the halls to lectures. In a valid assignment, the capacity of the hall assigned to a lecture should be greater or equal than the number of students attending.
If there exist multiple valid assignments, compute the assignment which maximizes the niceness of the lecture hall of the friendliest professor. If there are still multiple assignments, maximize the niceness of the lecture hall of lecturer 2, and so on.
The input consists of:
If there is a valid assignment, output a line with $n$ numbers, with the $i$th being equal to the number of the lecture hall that gets assigned to lecture $i$.
If there is no valid assignment, output "impossible".
3 3 4 5 6 6 5 5
2 3 1
5 5 3 2 1 4 8 6 8 1 7 5
1 4 3 5 2