#K76602. Election Results Allocation

    ID: 34679 Type: Default 1000ms 256MiB

Election Results Allocation

Election Results Allocation

In this problem, you are given two integers \(n\) and \(m\) representing the number of seats and the number of candidates, respectively. You are also given a list of \(n\) integers representing the weights of the seats and a list of \(m\) integers representing the influences of the candidates.

The allocation process is as follows: the candidate with the highest influence is allocated the seat with the highest weight, the candidate with the second highest influence gets the second best seat, and so on. If there are more candidates than seats, the remaining candidates get None as their result. The final output should list the allocated seat weights for each candidate in the same order as the input list of candidate influences, with each value separated by a space.

Note: All formulas are represented in \(\LaTeX\). For example, \(n\) denotes the number of seats and \(m\) the number of candidates.

inputFormat

The input is provided via stdin and consists of three lines:

  1. The first line contains two integers \(n\) and \(m\) separated by a space, where \(n\) is the number of seats and \(m\) is the number of candidates.
  2. The second line contains \(n\) integers representing the weights of the seats (if \(n > 0\)); otherwise, this line will be empty.
  3. The third line contains \(m\) integers representing the influences of the candidates.

outputFormat

The output is printed to stdout as a single line containing the allocated seat weights for each candidate in the order of their original input. If a candidate does not secure a seat, output None for that candidate. The outputs are separated by a space.

## sample
3 4
30 20 10
80 50 40 10
30 20 10 None