def max(a,b):return a if a>b else b w, u, lt = [0] * 21, [0] * 501, [0] * 21 t, d = [[0] * 21 for _ in range(21)], [[0] * 21 for _ in range(21)] c = [[0] * 501 for _ in range(21)] m,n=map(int,input().split()) inputs=list(map(int,input().split())) for i in range(1,m*n+1):u[i]=inputs[i-1] for i in range(1,n+1): inputs=list(map(int,input().split())) for j in range(1,m+1):d[i][j]=inputs[j-1] for i in range(1,n+1): inputs=list(map(int,input().split())) for j in range(1,m+1):t[i][j]=inputs[j-1] ans=s=0 for i in range(1,n*m+1): w[u[i]]+=1 j=lt[u[i]]+1 while True: if c[d[u[i]][w[u[i]]]][j]==0:s+=1 else:s=0 if s==t[u[i]][w[u[i]]]: for k in range(j-s+1,j+1):c[d[u[i]][w[u[i]]]][k]=1 lt[u[i]]=j s=0 break j+=1 for i in range(1,n+1):ans=max(ans,lt[i]) print(ans)
0.0分
1 人评分