Inspiring Professors
시간 제한3초메모리 제한2048 MB
각 강의에 정원이 충분한 강의실을 배정하되, 친근한 교수 순서대로 더 좋은 강의실을 주는 사전순 최적 배정을 구한다.
문제
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 lectures that happen at the same time, numbered to . In the th course, 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 .
There are lecture halls. The lecture halls are numbered from to and the th lecture hall has capacity . The list of 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:
- One line containing two integers () and (), the number of lectures and halls, respectively.
- The next line contains integers , with () the number of students attending the th lecture.
- The last line contains integers , with () the capacity of lecture hall .
출력
If there is a valid assignment, output a line with numbers, with the th being equal to the number of the lecture hall that gets assigned to lecture .
If there is no valid assignment, output "impossible".