There is a battle where n heroes are trying to defeat m monsters. You are given two 1-indexed arrays of positive integers heroes and monsters of length n and m, respectively.
heroes[i] is the power of the i-th hero, and monsters[i] is the power of the i-th monster. The i-th hero can defeat the j-th monster if monsters[j] <= heroes[i].
You are also given a 1-indexed array coins of length m consisting of positive integers. coins[i] is the number of coins that each hero earns after defeating the i-th monster.
Return an array ans of length n where ans[i] is the maximum number of coins that the i-th hero can collect from this battle.
Note: The health of a hero doesn't get reduced after defeating a monster. Multiple heroes can defeat a monster, but each monster can be defeated by a given hero only once.
Input & Output
Constraints
- 1 ≤ heroes.length, monsters.length ≤ 105
- 1 ≤ heroes[i], monsters[i] ≤ 108
- 1 ≤ coins[i] ≤ 108