結果

問題 No.243 出席番号(2)
ユーザー shotoyooshotoyoo
提出日時 2021-06-23 23:11:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 416 ms / 2,000 ms
コード長 677 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 30,400 KB
最終ジャッジ日時 2023-09-07 05:07:20
合計ジャッジ時間 7,347 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
29,696 KB
testcase_01 AC 131 ms
29,748 KB
testcase_02 AC 135 ms
29,676 KB
testcase_03 AC 143 ms
29,804 KB
testcase_04 AC 139 ms
29,744 KB
testcase_05 AC 140 ms
29,888 KB
testcase_06 AC 137 ms
29,736 KB
testcase_07 AC 139 ms
29,884 KB
testcase_08 AC 155 ms
30,000 KB
testcase_09 AC 145 ms
29,972 KB
testcase_10 AC 138 ms
29,820 KB
testcase_11 AC 139 ms
29,984 KB
testcase_12 AC 163 ms
29,840 KB
testcase_13 AC 180 ms
30,076 KB
testcase_14 AC 154 ms
30,076 KB
testcase_15 AC 146 ms
29,948 KB
testcase_16 AC 143 ms
30,028 KB
testcase_17 AC 213 ms
30,072 KB
testcase_18 AC 221 ms
30,120 KB
testcase_19 AC 171 ms
30,104 KB
testcase_20 AC 153 ms
30,188 KB
testcase_21 AC 150 ms
30,176 KB
testcase_22 AC 296 ms
30,124 KB
testcase_23 AC 265 ms
30,196 KB
testcase_24 AC 187 ms
30,244 KB
testcase_25 AC 162 ms
30,284 KB
testcase_26 AC 155 ms
30,128 KB
testcase_27 AC 416 ms
30,400 KB
testcase_28 AC 135 ms
29,800 KB
testcase_29 AC 135 ms
29,664 KB
testcase_30 AC 132 ms
29,672 KB
testcase_31 AC 134 ms
29,768 KB
testcase_32 AC 134 ms
29,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))

import numpy as np
n = int(input())
a = ([int(input()) for _ in range(n)])
count = [0]*5000
for v in (a):
    count[v] += 1
M = 10**9+7
ans = 0
dp = np.zeros(n+1, dtype=np.int64)
dp[0] = 1
for k in range(n):
    v = count[k]
    if v==0:
        continue
    dp[1:] += dp[:-1]*v%M
g = [1]
dp = dp.tolist()
for i in range(1,n+1):
    g.append(g[-1]*i%M)
s = 1
for i in range(n+1):
    ans += s * dp[i] * g[n-i] % M
    ans %= M
    s *= -1
print(ans%M)
0