Prizes
The organizers of the IDDA Cup are arranging T-shirts for the final round, with gift- presenters and boxes at their disposal. Each gift-presenter is currently holding a specific number of T-shirts in their hands, and each box has a predetermined capacity for holding T-shirts. The number of T-shirts in the -th gift-presenter’s hands is and the capacity of the -th box is . Currently the boxes are empty and organizers want to distribute the T-shirts that the gift-presenters hold to the boxes so that they can rest a bit. However, they cannot exceed the capacity of any box.
For each gift-presenter numbered from to , the T-shirts that the -th of them holds can be placed in the -th and -th box.
Find the maximum number of T-shirts that can be distributed into boxes, if organizers make the optimal distribution.
Input
Contains zero or more test cases, and is terminated by end-of-file. For each test case:
The first line contains an integer .
The second line contains integers .
The third line contains integers .
It is guaranteed that the sum of all does not exceed .
Output
For each test case, print in a new line the maximum number of T-Shirts that can be distributed into boxes.
Examples
Scoring
This task consists of the following subtasks. If all tests of a subtask are passed, you will earn points for that subtask.
( points): , ;
( points): , ;
( points): ;