結果
問題 | No.1904 Never giving up! |
ユーザー | nephrologist |
提出日時 | 2022-04-15 22:27:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 1,546 bytes |
コンパイル時間 | 209 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 54,912 KB |
最終ジャッジ日時 | 2024-06-07 03:27:24 |
合計ジャッジ時間 | 1,334 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
54,400 KB |
testcase_01 | AC | 56 ms
54,912 KB |
testcase_02 | AC | 45 ms
54,272 KB |
testcase_03 | AC | 45 ms
54,912 KB |
testcase_04 | AC | 43 ms
54,272 KB |
testcase_05 | AC | 43 ms
54,400 KB |
testcase_06 | AC | 44 ms
54,912 KB |
testcase_07 | AC | 45 ms
54,656 KB |
testcase_08 | AC | 44 ms
54,528 KB |
testcase_09 | AC | 45 ms
54,272 KB |
testcase_10 | AC | 46 ms
54,528 KB |
testcase_11 | AC | 47 ms
54,400 KB |
ソースコード
import sys from functools import lru_cache input = sys.stdin.buffer.readline sys.setrecursionlimit(4100000) n = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) # @lru_cache(None) # def calc(bit): # # print("bit", bit) # if bit == (1 << n) - 1: # return 1 # res = 0 # mx = -1 # for i in range(n): # if (bit >> i) & 1: # mx = max(mx, A[i]) # ok = 0 # ng = 0 # for i in range(n): # if (bit >> i) & 1: # continue # if A[i] >= mx: # ok += 1 # else: # ng += 1 # assert ok + ng > 0 # # ratio = 1 / (ok + ng) # prod = 1 # if ng: # return 0 # if not ok: # return 0 # for i in range(n): # if (bit >> i) & 1: # continue # nbit = bit | (1 << i) # if A[i] >= mx: # prod *= calc(nbit) # goukei = 0 # for i in range(n): # if (bit >> i) & 1: # continue # nbit = bit | (1 << i) # if A[i] >= mx: # goukei += prod // calc(nbit) # print("bit", bin(bit), "prod", prod, "goukei", goukei) # res = (ok + ng) * prod // goukei # return res # cnt = 100 # ok = 1 # ng = 0 # print(calc(0)) from collections import Counter CA = Counter(A) keys = sorted(list(CA.keys()), reverse=True) bunbo = 1 bunshi = 1 total = n for key in keys: num = CA[key] while num: bunbo *= total total -= 1 bunshi *= num num -= 1 print(bunbo // bunshi)