Task
people are standing on the axis. For each person, you have two arrays of elements and , where
The people are labeled such that the array is in ascending order.
Each person wants to find their soulmate, so a compatibility index has been created. Person is willing to travel at most meters to another person (including themselves), but for each meter traveled, the compatibility decreases by a global coefficient. Formally, the compatibility between two people is defined as:
Display for each person who is the suitable person (the index of the person where the compatibility is maximum).
Attention: It is ensured that the positions where they will travel the most (see constraints) are in ascending order. We can think that, the further people are from the origin, the less motivated they are to travel so much.
Input data
The first line of the input file pofta.in
contains two natural numbers and . The next lines contain the arrays , , and , all with the significance given in the task.
Output data
The first line of the output file pofta.out
will contain an array of natural numbers with the property that is maximum for each (of course )
Constraints and clarifications
- ;
- Let and be the leftmost and rightmost positions person can reach, respectively: and for each
- For each , is unique
Example 1
pofta.in
5 1
2 6 9 13 14
9 14 10 7 14
5 3 1 2 3
pofta.out
2 2 3 5 5
Explanation
The 5 people on the axis and their accessibility:
The values are written in the table below. We leave the cells empty where .
1 | 2 | 3 | 4 | 5 | |
---|---|---|---|---|---|
1 | 9 | 10 | |||
2 | 14 | 7 | |||
3 | 10 | ||||
4 | 7 | 13 | |||
5 | 6 | 14 |