Time limit
2s
Memory limit
128 MB
You will pick up trash on the same road for two days.
Each day, you start at the position of the first piece of trash and walk in one direction to the position of the N-th piece of trash. Because you cannot walk back, the pieces you pick on each day must form a subsequence in that day's position order. You do not have to pick up every piece of trash.
Because the trash bags are broken, all of the following conditions must hold.
2, 3, 5, 6 on the first day, then on the second day you must pick exactly 2, 3, 5, 6 in that order, and no other pieces.Find the maximum number of pieces of trash you can pick per day.
The first line contains the number of pieces of trash, N. (N ≤ 1,000)
The second line contains N integers, the sizes of the trash on the first day in position order.
The third line contains N integers, the sizes of the trash on the second day in position order.
Each trash size is a positive integer not greater than 50,000.
Print the maximum number of pieces of trash that can be picked per day.