# Practice on Toph

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

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

“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 `$N$`

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.

First line will contain `$N$`

`$( 1 \leq N \leq 10^{3})$`

, represents the number of people participating in the experiment.

Second line contains `$A_1, A_2, A_3, ..., A_N$`

`$(0 \leq A_i \leq 10^{5})$`

- the elements of the array `$A$`

, which represents the privilege points of each participant.

Third line contains `$B_1, B_2, B_3, ..., B_N$`

`$(0 \leq B_i \leq 10^{5})$`

- the elements of the array `$B$`

, which represents the points of free resources.

Output an array of length `$N$`

, 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.

Input | Output |
---|---|

4 12 2 11 30 20 13 6 20 | 36 25 31 22 |

Input | Output |
---|---|

5 8 10 7 4 10 9 15 12 10 14 | 19 20 20 21 19 |

99% Solution Ratio

sunkuet02Earliest,

prodip_bsmrstuFastest, 0.0s

sunkuet02Lightest, 131 kB

xerox38Shortest, 165B

Login to submit