반응형
1959 두 개의 숫자열
-
[SW Expert Academy] 1959. 두 개의 숫자열Algorithm/Source Code 2022. 7. 12. 21:09
solution.py T = int(input()) # 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다. for test_case in range(1, T + 1): N,M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) if N > M: N,M = M,N A,B = B,A result = [] # 짧은 배열만큼 돌면서 곱의 합 저장 for i in range(M-N+1): tmp = 0 for j in range(N): tmp += A[j]*B[i+j] result.append(tmp) print("#{} {}".format(test_case, max(result)))