Backtracking

    [Python] ๋ฐฑ์ค€ 10819 ์ฐจ์ด๋ฅผ ์ตœ๋Œ€๋กœ | ์ˆœ์—ด/์กฐํ•ฉ | Permutations/Combinations

    ~์‹ค๋ฒ„ 2~ ๋ฐฑํŠธ๋ž˜ํ‚น(Backtracking) ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ํ•™์Šตํ•˜๋Š” ๊ณผ์ •์—์„œ ๋งŒ๋‚œ ๋ฐฑ์ค€ ๋ฌธ์ œ! https://www.acmicpc.net/problem/10819 10819๋ฒˆ: ์ฐจ์ด๋ฅผ ์ตœ๋Œ€๋กœ ์ฒซ์งธ ์ค„์— N (3 ≤ N ≤ 8)์ด ์ฃผ์–ด์ง„๋‹ค. ๋‘˜์งธ ์ค„์—๋Š” ๋ฐฐ์—ด A์— ๋“ค์–ด์žˆ๋Š” ์ •์ˆ˜๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๋ฐฐ์—ด์— ๋“ค์–ด์žˆ๋Š” ์ •์ˆ˜๋Š” -100๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™๊ณ , 100๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™๋‹ค. www.acmicpc.net [์ตœ์ข… ์ฝ”๋“œ] from itertools import permutations n = int(input()) alist = list(map(int, input().split())) maxN = 0 nPr = permutations(alist) for p in nPr: temp = 0 for i in range(n-1): ..