Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Let There Be Equity

By shovo_kuet · Limits 1s, 512 MB

“Wonderland”, the society, recently took an outstanding initiative to run a social experiment on people. The aim of this experiment is to make the privileged people understand how to use free resource with the least point and leave the resources with more points for others who need the most. This is known as the Rule of Equity.

The authority wants to perform the experiment on NN people, where each of them will have points according to how privileged they are. One who has more points is considered to be more privileged. Then they will be given resources to choose from. Each of them has to choose exactly one resource for them obeying the “rule of equity”. In this experiment, person with higher points will choose the resource earlier. Their final privilege point will be the sum of earlier privilege point and the point of chosen free resource.

You are one of the judges of this experiment, so you want to find the final privilege point of each candidate.

Input

First line will contain NN (1N103)( 1 \leq N \leq 10^{3}), represents the number of people participating in the experiment.

Second line contains A1,A2,A3,...,ANA_1, A_2, A_3, ..., A_N (0Ai105)(0 \leq A_i \leq 10^{5}) - the elements of the array AA, which represents the privilege points of each participant.

Third line contains B1,B2,B3,...,BNB_1, B_2, B_3, ..., B_N (0Bi105)(0 \leq B_i \leq 10^{5}) - the elements of the array BB, which represents the points of free resources.

Output

Output an array of length NN, which represents the total points of each candidate. Output the point of person in the order of they select the resources.
N.B. Don't print any extra space at the end of any line.

Samples

InputOutput
4
12 2 11 30
20 13 6 20
36 25 31 22
InputOutput
5
8 10 7 4 10
9 15 12 10 14
19 20 20 21 19

    Discussion

    Statistics


    99% Solution Ratio

    sunkuet02Earliest, Jul '20

    prodip_bsmrstuFastest, 0.0s

    sunkuet02Lightest, 131 kB

    bokaifShortest, 113B

    Submit

    Login to submit

    Toph uses cookies. By continuing you agree to our Cookie Policy.