编程题:Assign Cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child $i$ has a greed factor $g_i$ , which is the minimum size of $a$ cookie that the child will be content with; and each cookie $j$ has a size $s_j$ . If $s_j >= g_i$ , we can assign the cookie $j$ to the child $i$ , and the child $i$ will be content. Your goal is to maximize the number of your content children and output the maximum number.
Note:
You may assume the greed factor is always positive.
You cannot assign more than one cookie to one child.
### Input:
The first line contains an integer $T_1(1 \leq T_1 \leq 10^3)$, representing the number of children.
The second line of input contains $T_1$ greed factors, the $i-{th}$ children has $ g_i(1 \leq g_i \leq 10^6) $greed factors .
The third line contains an integer $T_2(1 \leq T_2 \leq 10^3)$, representing the number of Cookies.
The Fourth line of input contains $T_2$ Cookies, the $i-{th}$ Cookie has $ s_i(1 \leq s_i \leq 10^6)$ size.
### Output:
output the maximum number of children
### Sample Input:
in
3
1 2 3
2
1 1
in
2
1 2
3
1 2 3
### Sample Output:
out
1
out
2
答案:若无答案欢迎评论
Note:
You may assume the greed factor is always positive.
You cannot assign more than one cookie to one child.
### Input:
The first line contains an integer $T_1(1 \leq T_1 \leq 10^3)$, representing the number of children.
The second line of input contains $T_1$ greed factors, the $i-{th}$ children has $ g_i(1 \leq g_i \leq 10^6) $greed factors .
The third line contains an integer $T_2(1 \leq T_2 \leq 10^3)$, representing the number of Cookies.
The Fourth line of input contains $T_2$ Cookies, the $i-{th}$ Cookie has $ s_i(1 \leq s_i \leq 10^6)$ size.
### Output:
output the maximum number of children
### Sample Input:
in
3
1 2 3
2
1 1
in
2
1 2
3
1 2 3
### Sample Output:
out
1
out
2
答案:若无答案欢迎评论