Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- n = int(input())
- ar = list(map(int, input().split()))
- sh = True
- best = sum(ar) + 100
- ans = []
- flr = []
- for i in range(1, n + 1):
- flr.append(i)
- idx = list(set(itertools.permutations(flr)))
- if sh:
- print(idx)
- for var in idx:
- S = 0
- for i in range(n):
- S += ar[i] / var[i]
- if sh:
- print(var)
- print(S)
- if S < best:
- best = S
- ans = var
- if sh:
- print()
- if sh:
- print("best ans")
- print(best)
- print(ans)
- print()
- get = []
- for i in range(n):
- get.append(0)
- for i in range(n):
- get[i] = ar[ ans[i] - 1]
- print(get)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement