Logo
(追記) (追記ここまで)

33367번 - Poor Students 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 2048 MB2110666.667%

문제

End of semester is coming, and it is a hard time for students. There are $k$ courses and $n$ students, and every student should pick exactly one course and pass the exam on it.

If student $i$ picks exam $j,ドル the student's frustration will be $c_{i,j}$. The total frustration of students is the sum of their individual frustrations.

The teachers insist that, for each exam $j,ドル no more than $a_j$ students can pick this exam. What is the minimum possible total frustration the students may get?

입력

The first line contains two integers $n$ and $k$: the number of students and the number of exams (1ドル \le n \le 50,000円,ドル 1ドル \le k \le 10$).

Then follow $n$ lines. In $i$-th of these lines, there are $k$ integers $c_{i,1}, c_{i,2}, \ldots, c_{i,k}$: the frustration of student $i$ if they choose the exam 1,ドル 2, \ldots, k$ (1ドル \le c_{i,j} \le 10^9$).

The last line contains $k$ integers $a_1, a_2, \ldots, a_k$: the maximum number of students that can pick exam 1,ドル 2, \ldots, k$ (0ドル \le a_j \le n$). It is guaranteed that $\sum a_j \ge n$.

출력

Print one integer: the minimum possible total frustration.

제한

예제 입력 1

6 2
1 2
1 3
1 4
1 5
1 6
1 7
3 4

예제 출력 1

12

예제 입력 2

3 3
1 2 3
2 4 6
6 5 4
1 1 1

예제 출력 2

8

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2023 > Day 4: SPb SU Contest, LVII SPb SU Championship K번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /