题目描述
Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts together to form her favorite color stripe.
It is said that a normal human eye can distinguish aboutless than200 different colors, so Eva's favorite colors are limited. However the original stripe could be very long, and Eva would like to have the remaining favorite stripe withthe maximum length. So she needs your help to find her the best result.
Note thatthe solution might not be unique, but you only have totell her the maximum length. For example, given a stripe of colors {224155631156}. If Eva's favorite colors are givenin her favorite order as {23156}, then she has 4 possible best solutions {2211156}, {2215556}, {2215566}, and {2231156}.
输入描述:
Each input filecontains one test case. For each case, thefirst line contains a positive integer N (<=200) which isthe total numberof colors involved (and hence the colors are numbered from1to N). Then the next line starts with a positive integer M (<=200) followed by M Eva's favorite color numbers givenin her favorite order. Finally thethird line starts with a positive integer L (<=10000) which isthelengthofthegiven stripe, followed by L colors onthe stripe. All the numbers in a line are separated by a space.
输出描述:
For each test case, simply print in a line the maximum lengthof Eva's favorite stripe.
输入例子:
652315612224155631156
输出例子:
7
题目题目描述Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remainin