#P8051. [ZYOI Round1] Bird/鸟
[ZYOI Round1] Bird/鸟
Background

The river porpoise stands amid splashing waves, and the shore bird leisurely catches fish.
Problem Description
A bird is flying among trees. The height of the -th tree is , arranged from left to right. This bird is too heavy to fly upward, so it can only glide to the left or to the right.
If the bird is currently standing on a tree of height , then the height of the tree it can fly to must be less than , and the heights of all trees it passes over during the flight must also be less than .
The bird has teleport cards. The magic value of the -th card is . The bird may choose to use a teleport card on any tree, teleporting to a tree whose height is not greater than the magic value of that card (if the height of the tree where the bird currently is is not greater than the card’s magic value, then it may teleport to the current tree). However, it can only use the teleport cards in the given order. The testdata guarantees that all teleport cards can be used (that is, there is no teleport card whose magic value is less than the heights of all trees).
The bird starts at the first tree. Please compute the maximum number of flights it can make (teleports are not counted).
Note: The bird may pass through the same tree multiple times.
Input Format
The first line contains two integers , representing the number of trees and the number of teleport cards.
The next line contains integers, representing the height of each tree.
The next line contains integers, representing the magic value of each teleport card, given in the order they are used.
Output Format
Output one line with one integer, representing the maximum number of flights the bird can make.
3 1
1 5 2
6
1
5 2
1 3 2 7 1
4 10
3
Hint
For of the data, .
For of the data, .
For of the data, .
For of the data, , .
Translated by ChatGPT 5