#P11789. Maximum Exhibition Paintings

    ID: 13885 Type: Default 1000ms 256MiB

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 NN candidate paintings numbered from 11 to NN. Painting ii has a size SiS_i and an aesthetic value ViV_i.

There are also MM candidate frames numbered from 11 to MM. The jj-th frame has a capacity of CjC_j. Only a painting whose size does not exceed CjC_j can be placed in frame jj. 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