結果
| 問題 |
No.1904 Never giving up!
|
| コンテスト | |
| ユーザー |
nephrologist
|
| 提出日時 | 2022-04-15 22:27:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 2,000 ms |
| コード長 | 1,546 bytes |
| コンパイル時間 | 167 ms |
| コンパイル使用メモリ | 82,384 KB |
| 実行使用メモリ | 55,852 KB |
| 最終ジャッジ日時 | 2024-12-25 01:17:51 |
| 合計ジャッジ時間 | 1,371 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
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)
nephrologist