아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Gym Badges

시간 제한1.5초메모리 제한1024 MB

요약
현재 레벨이 L_i 이하일 때만 gym i를 깨서 레벨을 X_i만큼 올릴 수 있다. 깰 수 있는 gym의 최대 개수를 구한다.
난이도

보통10점 중 7점

유형
그리디, 정렬, 힙
정답자
아직 제출이 없습니다

문제

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 00 and can only gain levels by challenging gyms. There are NN gyms numbered from 11 to NN spread across the region and you can challenge them in any order. To prevent over grinding, gym ii has its own level cap L_iL\_i where you can only challenge the gym if Wabbit’s current level is less than or equal to L_iL\_i.

As there may be different number of trainers to defeat in a gym, the number of levels that Wabbit gains after challenging a gym may differ. To be precise, Wabbit will gain X_iX\_i levels after challenging gym ii.

Each gym ii rewards successful challengers with their own unique gym badge ii. Find the maximum number of unique gym badges that you can obtain if you challenge the gyms in an optimal way.

입력

Your program must read from standard input.

The first line contains an integer NN, the number of gyms.

The second line contains NN integers, where the iith integer represents the level Wabbit gains by challenging iith gym, X_iX\_i.

The third line contains NN integers, where the iith integer represents the level cap of the iith gym, L_iL\_i.

출력

Your program must print to standard output.

The output should contain a single integer on a single line, the maximum number of unique gyms badges that can be won.

제한

  • 1≤N≤500,0001 ≤ N ≤ 500\\,000
  • 1≤X_i,L_i≤1091 ≤ X\_i , L\_i ≤ 10^9

예제2

  1. 예제 1

    입력
    5
    4 6 3 5 2
    10 6 4 8 12
    
    예상 출력
    4
    
  2. 예제 2

    입력
    5
    3 9 4 2 6
    10 10 10 10 10
    
    예상 출력
    4