Algorithm/Brute force5 [백준] 10819번 차이를 최대로 from itertools import permutations를 활용하면 성능은 좀 그렇지만 쉽게 구현이 가능하다.. from itertools import permutations lengthOfData = int(input()) dataList = list(map(int, input().split())) ans = 0 for i in permutations(dataList): tempVal = 0 for j in range(lengthOfData - 1): tempVal += abs(i[j] - i[j + 1]) ans = max(ans, tempVal) print(ans) 2021. 2. 5. [백준] 14888번 연산자 끼워넣기 from itertools import permuitations를 사용하면 쉽게 풀 수 있다. from itertools import permutations import copy import sys input() minVal = 1000000000 maxVal = -1000000000 dataList = list(map(int, sys.stdin.readline().split())) methodList = list(map(int, sys.stdin.readline().split())) methodStr = "" methodStr += "+" * methodList[0] methodStr += "-" * methodList[1] methodStr += "*" * methodList[2] methodStr .. 2021. 2. 5. [백준] 1182 부분수열의 합 진짜... 파이썬에 이런 미친 모듈이 있었다니.... from itertools import combinations 활용 무조건 기억 from itertools import combinations N, S = map(int, input().split()) dataList = list(map(int, input().split())) ans = 0 for i in range(1, len(dataList) + 1): tempList = list(combinations(dataList, i)) for j in range(len(tempList)): sumVal = sum(tempList[j]) if sumVal == S: ans += 1 print(ans) 2021. 2. 4. [백준] 2309번 일곱 난쟁이 9개의 데이터에서 2개만 제거하면 되는거니까 쉬운 문제 dataList = [] for _ in range(9): dataList.append(int(input())) dataList.sort() sumVal = sum(dataList) for i in range(9): for j in range(i + 1, 9): if sumVal - dataList[i] - dataList[j] == 100: for k in range(9): if k != i and k != j: print(dataList[k]) exit() 2021. 2. 4. 이전 1 2 다음