Cucumber - MarisaOJ: Marisa Online Judge

Cucumber

Time limit: 1000 ms
Memory limit: 256 MB
Nitori's cucumber garden has n cucumbers that need to be harvested. Harvesting a cucumber requires exactly one unit of time, and the i-th cucumber needs to be harvested before time ai. Not harvesting the i-th cucumber will incur a loss of bi. Help Nitori harvest the cucumbers in an optimal order to minimize the loss. ### Input - The first line contains two integers n. - The second line contains n integers ai. - The third line contains n integers bi. ### Output - Print an integer, the minimum loss. ### Constraints - 1≤n≤1000. - 1≤ai,bi≤1000. ### Example Input: 5132311040302015 Output: 25