#P11789. Maximum Exhibition Paintings
Maximum Exhibition Paintings
Maximum Exhibition Paintings
You are organizing an art exhibition. In the exhibition, you want to display some paintings by placing them into available frames and arranging them in a row.
There are candidate paintings numbered from to . Painting has a size and an aesthetic value .
There are also candidate frames numbered from to . The -th frame has a capacity of . Only a painting whose size does not exceed can be placed in frame . Each frame can hold at most one painting, and every painting on display must be placed in a frame.
Moreover, for aesthetic reasons, the displayed paintings must satisfy the following conditions when arranged in a row:
- For any two adjacent paintings, the capacity of the frame on the right is not less than that of the frame on the left, i.e. $$C_{j_1} \le C_{j_2}$$ for consecutive frames.
- For any two adjacent paintings, the aesthetic value of the painting on the right is not less than that of the painting on the left, i.e. $$V_{i_1} \le V_{i_2}$$ for consecutive paintings.
Determine the maximum number of paintings that can be exhibited under these conditions.
inputFormat
The input is given from standard input and has the following format:
N M
S₁ S₂ … Sₙ
(the sizes of the paintings)
V₁ V₂ … Vₙ
(the aesthetic values of the paintings)
C₁ C₂ … Cₘ
(the capacities of the frames)
outputFormat
Output to standard output a single integer: the maximum number of paintings that can be exhibited.
sample
3 3
1 2 3
1 2 3
1 2 3
3