시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 215 | 125 | 114 | 59.067% |
You are going to hold an exhibition of pictures. In the exhibition, you will put some pictures into frames and exhibit them, lining them up in a row.
There are N candidate pictures for the exhibition, numbered from 1 through N. The picture i (1 ≤ i ≤ N) has size Si and value Vi.
Also, there are M frames for the pictures, numbered from 1 through M. The frame j (1 ≤ j ≤ M) has size Cj. Only pictures of size at most Cj can be put into the frame j. At most one picture can be put into a frame.
Every picture to be exhibited must be put into a frame. For the sake of appearance, they must satisfy the following conditions:
You want to exhibit as many pictures as possible.
Write a program which, given the number of pictures, the number of frames, and their sizes and values, calculates the maximum number of pictures to be exhibited.
Read the following data from the standard input.
N M S1 V1 . . . SN VN C1 . . . CM
Write one line to the standard output. The output should contain the maximum number of pictures to be exhibited.
번호 | 배점 | 제한 |
---|---|---|
1 | 10 | N ≤ 10, M ≤ 10. |
2 | 40 | N ≤ 1000, M ≤ 1000. |
3 | 50 | No additional constraints. |
3 4 10 20 5 1 3 5 4 6 10 4
2
In this sample, you can exhibit 2 pictures by lining them up as (picture 2, frame 2), (picture 1, frame 3) from left to right. As you cannot exhibit 3 or more pictures, output 2. Here, (picture i, frame j) denotes the picture i put in the frame j.
3 2 1 2 1 2 1 2 1 1
2
4 2 28 1 8 8 6 10 16 9 4 3
0
8 8 508917604 35617051 501958939 840246141 485338402 32896484 957730250 357542366 904165504 137209882 684085683 775621730 552953629 20004459 125090903 607302990 433255278 979756183 28423637 856448848 276518245 314201319 666094038 149542543
3