410813: GYM104120 C Company Layoffs
Description
The tech company, Weta, has announced that it will continue to make layoffs once a week for the next $$$M$$$ weeks.
For the layoffs, Weta has established that it will fire all employees who have a score greater than $$$Q_i$$$. $$$Q_i$$$ is different every week, and obviously the current week score must be lower than the previous one.
Fortunately, the employees know about this in advance. That is why everyone who would be affected by the week's layoff must make their score equal to $$$Q_i$$$.
Weta will not notice this, since Weta does not care about the number of employees fired, but the sum of the employees score.
You, as the representative of the employees, must give Weta the sum of the scores once they have all adjusted their scores to avoid being fired.
Note that only employees with a score greater than $$$Q_i$$$ can change their score.
InputThe first line of input contains two integer $$$N$$$, $$$M$$$ ($$$1$$$ $$$\leq$$$ $$$M$$$ < $$$N$$$ $$$\leq$$$ $$$10^5$$$), the number of employees in Weta and the number of layoffs.
The next line contains $$$N$$$ integers $$$S_i$$$ ($$$1$$$ $$$\leq$$$ $$$S_i$$$ $$$\leq$$$ $$$10^9$$$)
The following $$$M$$$ lines describe the layoffs. The i-th of them contains $$$Q_i$$$, the score for the layoff of the $$$i-th$$$ week. ($$$1$$$ $$$\leq$$$ $$$Q_i$$$ $$$\leq$$$ $$$10^9$$$)
OutputPrint $$$M$$$ lines with the sum of employees' scores.
ExampleInput5 3 2 3 5 5 10 8 7 1Output
23 22 5