Logo
(追記) (追記ここまで)

33227번 - Inspiring Professors 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB183318.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:

  • One line containing two integers $n$ (1ドル\leq n\leq 5000$) and $m$ (1ドル\leq m \leq 5000$), the number of lectures and halls, respectively.
  • The next line contains $n$ integers $x_i,ドル with $x_i$ (1ドル\leq x_i \leq 10^9$) the number of students attending the $i$th lecture.
  • The last line contains $m$ integers $c_j,ドル with $c_j$ (1ドル\leq c_j \leq 10^9$) the capacity of lecture hall $j$.

출력

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".

제한

예제 입력 1

3 3
4 5 6
6 5 5

예제 출력 1

2 3 1

예제 입력 2

5 5
3 2 1 4 8
6 8 1 7 5

예제 출력 2

1 4 3 5 2

힌트

출처

University > Delft University of Technology > Freshmen Programming Contest 2022 I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /