[SW Expert Academy, SWEA 1959] 두 개의 숫자열 (python)
Problem Solving/SWEA

[SW Expert Academy, SWEA 1959] 두 개의 숫자열 (python)

728x90

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5PpoFaAS4DFAUq&categoryId=AV5PpoFaAS4DFAUq&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=2&pageSize=10&pageIndex=2

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


※ SW Expert 아카데미의 문제를 무단 복제하는 것을 금지합니다.

728x90

T = int(input())

for test_case in range(1, T + 1):
    N, M = map(int, input().split())

    #항상 더 긴 배열이 arr2, 짧은 배열이 arr1
    if N > M:
        arr2 = list(map(int, input().split()))
        arr1 = list(map(int, input().split()))
    else:
        arr1 = list(map(int, input().split()))
        arr2 = list(map(int, input().split()))

    #모든 경우의 수(|N - M| + 1)를 저장할 배열
    mulSum = [0] * (abs(N - M) + 1)
    for i in range(abs(N - M) + 1):
        for j in range(min(N, M)):
            mulSum[i] += arr1[j] * arr2[j + i]
    
    print("#{} {}".format(test_case, max(mulSum)))
728x90