108191 [백준] 차이를 최대로 / 10819번 / 파이썬 / Python 💡solutions ) 💬 n값이 크지 않으니까, permutations 써서 모든 경우를 찾는 브루트포스 알고리즘 구현 🎫code ) import sys from itertools import permutations as permu input = sys.stdin.readline n = int(input()) arr = list(map(int, input().rstrip().split(' '))) max_v = 0 for p in permu(arr, n): sum = 0 n_list = list(p) for i in range(1, len(n_list)): tmp = abs(n_list[i - 1] - n_list[i]) sum += tmp max_v = max(max_v, sum) print(max_.. 2020. 11. 30. 이전 1 다음