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 $a_i$. Not harvesting the $i$-th cucumber will incur a loss of $b_i$. 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 $a_i$. - The third line contains $n$ integers $b_i$. ### Output - Print an integer, the minimum loss. ### Constraints - $1 \leq n \leq 1000$. - $1 \leq a_i, b_i \leq 1000$. ### Example Input: ``` 5 1 3 2 3 1 10 40 30 20 15 ``` Output: ``` 25 ```