|
||||||||||
The MusselsTime Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 598 Accepted Submission(s): 272 Problem Description "To be or not to be, that is the question." Now FJ( Frank&John) faces a serious problem. FJ is breeding mussels these days. The mussels all want to be put into a culturist with a grade no little than their own grades. FJ accept their requirements. FJ provides culturists of different grades, all having a certain capacity. FJ first put mussels into culturists with the same grade until they are full. Then he may put some mussels into some potential culturists that still have capacity. Now, FJ wants to know how many mussels can be put into the culturists. Input For each data set: The first line contains two integers, n and m(0<n<=100000,0<m<=1000000), indicating the number of culturists and the number of mussels. The ith culturist has a grade i, and grade 1 is considered the highest. The second line contains n integers indicating the culturists' capacity in order. The third line contains m integers all in the range 1~n, indicating the mussels' grade in order. Proceed to the end of file. Output A single integer, which is the number of mussels that can be put into the culturists. Sample Input
Sample Output
Source | ||||||||||
|