結果

問題 No.1904 Never giving up!
ユーザー nephrologistnephrologist
提出日時 2022-04-15 22:27:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,546 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 72,416 KB
最終ジャッジ日時 2023-08-26 08:14:28
合計ジャッジ時間 2,125 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
72,300 KB
testcase_01 AC 97 ms
72,288 KB
testcase_02 AC 96 ms
72,416 KB
testcase_03 AC 96 ms
72,384 KB
testcase_04 AC 93 ms
72,256 KB
testcase_05 AC 93 ms
72,328 KB
testcase_06 AC 91 ms
72,280 KB
testcase_07 AC 93 ms
72,284 KB
testcase_08 AC 93 ms
72,416 KB
testcase_09 AC 95 ms
72,400 KB
testcase_10 AC 93 ms
72,288 KB
testcase_11 AC 94 ms
72,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0