RoAlgo PreOJI 2024 X | pofta

This was the problem page during the contest. Access the current page here.
Time limit: 0.6s Memory limit: 512MB Input: pofta.in Output: pofta.out

Task

NN people are standing on the OxOx axis. For each person, you have two arrays of NN elements dd and ff, where

di=the distance of person i from the originfi=the "beauty" of person id_i = \text{the distance of person } i \text{ from the origin} \newline f_i = \text{the "beauty" of person } i
The people are labeled such that the array dd is in ascending order.

Each person wants to find their soulmate, so a compatibility index has been created. Person ii is willing to travel at most depmaxidepmax_i 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:

comp(i,j)=dist(i,j)(coef)+fj for dist(i,j)depmaxiwhere dist(i,j)=the distance between person i and person jcomp(i, j) = dist(i, j) \cdot (-coef) + f_j \text{ for } dist(i, j) \leq depmax_i \newline \text{where } dist(i, j) = \text{the distance between person } i \text{ and person } j

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 1^1 (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 NN and coefcoef. The next 33 lines contain the arrays dd, ff, and depmaxdepmax, all with the significance given in the task.

Output data

The first line of the output file pofta.out will contain an array of NN natural numbers cc with the property that comp(i,ci)comp(i, c_i) is maximum for each ii (of course 1iN1 \leq i \leq N)

Constraints and clarifications

  • 1N1 000 0001 \leq N \leq 1 \ 000 \ 000;
  • 0di,depmaxi,fi10100 \leq d_i, depmax_i, f_i \leq 10^{10}
  • 1coef1 0001 \leq coef \leq 1 \ 000
  • 1^1 Let lil_i and rir_i be the leftmost and rightmost positions person ii can reach, respectively: lili+1l_i \leq l_{i+1} and riri+1r_i \leq r_{i+1} for each 1i<N1 \leq i < N
  • For each ii, cic_i 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 OxOx axis and their accessibility:

The values comp(i,j)comp(i, j) are written in the table below. We leave the cells empty where dist(i,j)>depmaxidist(i, j) > depmax_i.

ij_{i} \diagdown ^{j} 1 2 3 4 5
1 9 10
2 14 7
3 10
4 7 13
5 6 14

Log in or sign up to be able to send submissions!