You are viewing a single comment's thread. Return to all comments →
PYTHON3 LINEANT APPROACH
from collections import defaultdict N = int(input()) P = [int(x) for x in input().strip().split()] SP = sorted(P) if P == SP: print(0) else: facs = [1] for i in range(1, N+1): facs.append(facs[-1] * i) cnt = defaultdict(int) for x in P: cnt[x] += 1 acc = facs[N] for k, v in cnt.items(): acc /= facs[v] print("%.6f" % acc)
Seems like cookies are disabled on this browser, please enable them to open this website
Lazy Sorting
You are viewing a single comment's thread. Return to all comments →
PYTHON3 LINEANT APPROACH