AlgoLensArena
ContestlərProblemlərOtaqlar
Vizualizator
← Məsələlər

FPC22-024.Inspiring Professors

Easy · 3 s · 256 MB

  • icpc
  • fpc
  • 2022

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 nnn lectures that happen at the same time, numbered 111 to nnn. In the iiith course, xix_ixi​ 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 111.

There are mmm lecture halls. The lecture halls are numbered from 111 to mmm and the jjjth lecture hall has capacity cjc_jcj​. The list of mmm 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.

Giriş formatı

The input consists of:

• One line containing two integers nnn (1≤n≤50001\leq n\leq 50001≤n≤5000) and mmm (1≤m≤50001\leq m \leq 50001≤m≤5000), the number of lectures and halls, respectively.

• The next line contains nnn integers xix_ixi​, with xix_ixi​ (1≤xi≤1091\leq x_i \leq 10^91≤xi​≤109) the number of students attending the iiith lecture.

• The last line contains mmm integers cjc_jcj​, with cjc_jcj​ (1≤cj≤1091\leq c_j \leq 10^91≤cj​≤109) the capacity of lecture hall jjj.

Çıxış formatı

If there is a valid assignment, output a line with nnn numbers, with the iiith being equal to the number of the lecture hall that gets assigned to lecture iii.

If there is no valid assignment, output “impossible”.

Qeyd

Source: Freshmen Programming Contest 2022 · Author: Jeroen Op de Beek · License: CC BY-SA 4.0 · Original: https://fpc.wisv.ch · Statement adapted for AlgoLens and shared under the same license.

Nümunələr

Giriş #1

3 3
4 5 6
6 5 5

Çıxış #1

2 3 1

Giriş #2

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

Çıxış #2

1 4 3 5 2