시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 512 MB 2 0 0 0.000%

문제

There are N items numbered from 1 to N to be sold at an auction market on a particular day, and the ith item has a starting price of Si. There are M potential buyers numbered from 1 to M who want to participate in the auction, and the jth potential buyer has a budget of Bj.

Each potential buyer, one by one from the 1st to the Mth potential buyer consecutively, inspects each item, one by one from the 1st to the Nth item consecutively, and decides whether he is able to bid on that item. The jth potential buyer is able to bid on the ith item if and only if at least one of the following conditions is satisfied.

  • No one has bid the ith item yet and Bj ≥ Si.
  • Someone has bid the ith item and Bj is strictly larger than the largest existing bid for that ith item.

If the jth potential buyer is able to bid on the ith item, then he will bid that ith item at Bj and stop inspecting the remaining items, i.e. he will ignore the (i + 1)th to Nth items. With this behavior, each potential buyer will only bid at most 1 item. Note that it is also possible for a potential buyer to fail to bid on any item at all, i.e. when his budget is too low.

At the end of the day, after all the potential buyers have either placed their bid or inspected all items, the highest bid for each item is determined and the items are sold to the respective highest bidder. Items that do not have any bidder are not sold.

Your task is to find out how many items are successfully sold at the end of the day.

입력

Input begins with a line containing an integer: N (1 ≤ N ≤ 100 000) representing the number of items to be sold at the auction market. The second line contains N integers: Si (1 ≤ Si ≤ 109) representing the starting price of each item. The third line contains an integer M (1 ≤ M ≤ 100 000) representing the number of potential buyers. The fourth line contains M integers: Bj (1 ≤ Bj ≤ 109) representing the budget of each potential buyer.

출력

Output in a line an integer representing the number of items that are successfully sold at the end of the day.

예제 입력 1

3
100 200 150
5
110 250 220 130 140

예제 출력 1

2
  • The 1st potential buyer will bid the 1st item at B1 = 110 (no lower than the starting price S1 = 100).
  • The 2nd potential buyer will bid the 1st item at B2 = 250 (higher than the previous bid for this item, 110).
  • The 3rd potential buyer will bid the 2nd item at B3 = 220 (no lower than the starting price S2 = 200).
  • The 4th potential buyer cannot place any bid.
  • The 5th potential buyer cannot place any bid.

At the end of the day,

  • The 1st item is sold to the 2nd (potential) buyer at 250.
  • The 2nd item is sold to the 3rd (potential) buyer at 220.

Therefore, two items are sucessfully sold.

예제 입력 2

4
1000 1000 1000 1000
4
3000 2000 2500 1000

예제 출력 2

3

예제 입력 3

5
10 40 30 50 20
4
5 50 10 15

예제 출력 3

1