Gym Badges
InterviewTime limit1.5sMemory limit1024 MB
Given each gym's level gain X_i and level cap L_i, find the most gyms you can challenge when your level must be at most L_i before each fight.
Problem
In a quest to be the very best, you have decided to set out on your journey around the region to prove your strength by collecting gym badges. You begin your solo adventure with your first and only Pokemon, which happens to be a legendary Wabbit.
Your Wabbit starts at level and can only gain levels by challenging gyms. There are gyms numbered from to spread across the region, and you can challenge them in any order. To prevent over grinding, gym has its own level cap . You can only challenge the gym if Wabbit's current level is less than or equal to .
Each gym has a different number of trainers, so the number of levels Wabbit gains after a challenge differs by gym. Wabbit gains levels after challenging gym . Each gym rewards successful challengers with its own unique gym badge . Find the maximum number of unique gym badges you can obtain if you challenge the gyms in an optimal way.
Input
The first line contains an integer , the number of gyms. The second line contains integers, where the -th integer is , the level Wabbit gains by challenging gym . The third line contains integers, where the -th integer is , the level cap of gym .
Output
Print a single integer on one line, the maximum number of unique gym badges that can be won.
Constraints