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

33100번 - Horse Carts 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB19181894.737%

문제

You just found a cave filled with $N$ treasures (numbered from 1ドル$ to $N$). Treasure $i$ has a weight of $W_i$ and a value of $V_i$.

Luckily, you also bring $M$ horse carts (numbered from 1ドル$ to $M$) to help you carry the treasures. Each cart can only carry one treasure; cart $j$ can only carry a treasure with weight at most $S_j$.

Determine the maximum total value of treasures that you can take using your horse carts.

입력

The first line consists of two integers $N$ $M$ (1ドル ≤ N, M ≤ 100,円 000$).

Each of the next $N$ lines consists of two integers $W_i$ $V_i$ (1ドル ≤ W_i , V_i ≤ 10^6$).

The following line consists of $M$ integers $S_j$ (1ドル ≤ S_j ≤ 10^6$).

출력

Output a single integer representing the maximum total value of treasures that you can take using your horse carts.

제한

예제 입력 1

8 5
2 10
9 4
6 10
2 20
3 15
3 9
4 8
4 10
1 5 3 3 10

예제 출력 1

55

You can put treasures 8ドル,ドル 4ドル,ドル 5ドル$ and 3ドル$ to carts 2ドル,ドル 3ドル,ドル 4ドル,ドル and 5ドル,ドル respectively.

예제 입력 2

5 3
1 4
1 2
1 7
1 1
1 9
1 1 1

예제 출력 2

20

You can put treasures 1ドル,ドル 3ドル,ドル and 5ドル$ in any of your carts.

예제 입력 3

2 5
9 100
4 100
1 2 3 1 3

예제 출력 3

0

None of the treasures fit in any of your carts.

예제 입력 4

7 4
1 10
1 20
2 50
3 5
4 8
10 100
12 40
2 2 5 7

예제 출력 4

88

힌트

출처

ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2023 H번

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

출처

대학교 대회

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

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