Poor Students
시간 제한4초메모리 제한2048 MB
n명의 학생을 k개 시험에 배정하되 각 시험의 정원 a_j를 지키면서 전체 불만족도의 합을 최소로 만든다.
문제
End of semester is coming, and it is a hard time for students. There are courses and students, and every student should pick exactly one course and pass the exam on it.
If student picks exam , the student's frustration will be . The total frustration of students is the sum of their individual frustrations.
The teachers insist that, for each exam , no more than students can pick this exam. What is the minimum possible total frustration the students may get?
입력
The first line contains two integers and : the number of students and the number of exams (, ).
Then follow lines. In -th of these lines, there are integers : the frustration of student if they choose the exam ().
The last line contains integers : the maximum number of students that can pick exam (). It is guaranteed that .
출력
Print one integer: the minimum possible total frustration.