Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Ice-Cream of Montu Mia Again!

By Raiyan13 · Limits 1s, 512 MB

Montu Mia is a student of “Omok School”. He likes to eat an ice-cream every day. But he also likes to buy that ice-cream with his daily pocket money. His father always gives him maximum pocket money for the purpose of transportation costs only. Because his mother makes tiffin for him every day.

So, for Montu Mia, the only way to buy an ice-cream is saving money from his transportation cost as much as he can. There is only one ice-cream shop in his city, so he always goes to that shop and today ingredients of only one ice-cream is left. As the shop is the only shop and the owner is not so good, so he only gives icecream to them who give him only $1$ note which is the actual price of the ice-cream (if the price is $10$ taka you have to pay exactly $10$ taka note).

You are given $n$ number of notes Montu Mia has with their value and the $m$ number of ice-creams on the menu of the shop with their price. You have to help Montu Mia and tell the maximum number of ice-creams he can buy today.

Input

The first line contains a single integer $n \hspace{.1cm} (1 \leq n \leq 100)$ — number of notes given by Montu’s father.

The next line contains $n$ space separated integers the value of $n$ notes.

The third line contains a single integer $m \hspace{.1cm} (1 \leq m \leq 100)$ — number of ice-creams presents on shops’ menu.

The next line contains $m$ space separated integers the price of each of the $m$ ice-creams.

Output

Print an integer, the maximum number of ice-cream he can buy today.

Samples

InputOutput
5
9 2 3 5 13
5
1 4 6 8 13
1
InputOutput
3
5 9 13
2
1 3
0

    Discussion

    Statistics


    77% Solution Ratio

    Nowshin_SEarliest, 2w ago

    Nowshin_SFastest, 0.0s

    Sourav1234Lightest, 0 B

    mdvirusShortest, 334B

    Submit

    Login to submit