204

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
a=int(input())
X=list(map(int, input().split()))
b=int(input())
Y=list(map(int, input().split()))
Q=[[0]*(b+1) for i in range(a+1)]
for i in range(1,a+1):
for j in range(1,b+1):
if X[i-1]==Y[j-1]:
Q[i][j]=Q[i-1][j-1]+1
else:
Q[i][j]=max(Q[i-1][j],Q[i][j-1])
print(Q[i][j])