Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

第二题

Posted by 346248129 at 2008-09-20 09:03:21
TimeLimit : 1 Second   Memorylimit : 32 Megabyte   

Totalsubmit : 0   Accepted : 0

  "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<100000,0<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 

4 4
100 4 4 4
1 2 3 4
4 3
1 1 1 1
4 2 2 

Sample Output 

4
3 


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator