#C5135. Maximum Books with Bookmarks

    ID: 48751 Type: Default 1000ms 256MiB

Maximum Books with Bookmarks

Maximum Books with Bookmarks

You are given n books and m bookmarks. Each book has a weight and each bookmark has a weight capacity. A bookmark can be placed on a book if and only if the weight of the book does not exceed the capacity of the bookmark. Each bookmark can be used at most once, and the bookmarks are considered in a sorted order.

Your task is to determine the maximum number of books that can have a bookmark placed in them under these constraints.

Formally, given two sorted sequences (when sorted in non-decreasing order) \( w_1, w_2, \dots, w_n \) and \( c_1, c_2, \dots, c_m \) (representing the weights of books and the capacities of the bookmarks respectively), you are to find the maximum number of pairs \( (w_i, c_j) \) such that \( w_i \leq c_j \) with each bookmark used at most once.

inputFormat

The input is given from standard input (stdin) and consists of three lines:

  1. The first line contains two integers n and m: the number of books and bookmarks, respectively.
  2. The second line contains n integers representing the weights of the books.
  3. The third line contains m integers representing the capacities of the bookmarks.

outputFormat

Output a single integer representing the maximum number of books that can have a bookmark placed in them.

## sample
5 3
2 4 6 8 10
3 7 5
3