結果

問題 No.243 出席番号(2)
ユーザー shotoyooshotoyoo
提出日時 2021-06-23 23:00:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 799 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 8,872 KB
最終ジャッジ日時 2023-09-07 04:54:45
合計ジャッジ時間 10,299 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,408 KB
testcase_01 AC 16 ms
8,248 KB
testcase_02 AC 16 ms
8,196 KB
testcase_03 AC 80 ms
8,300 KB
testcase_04 AC 33 ms
8,468 KB
testcase_05 AC 25 ms
8,216 KB
testcase_06 AC 22 ms
8,400 KB
testcase_07 RE -
testcase_08 AC 264 ms
8,284 KB
testcase_09 AC 76 ms
8,436 KB
testcase_10 AC 42 ms
8,432 KB
testcase_11 AC 32 ms
8,256 KB
testcase_12 RE -
testcase_13 AC 603 ms
8,612 KB
testcase_14 AC 151 ms
8,572 KB
testcase_15 AC 73 ms
8,520 KB
testcase_16 AC 46 ms
8,492 KB
testcase_17 RE -
testcase_18 AC 1,059 ms
8,620 KB
testcase_19 AC 266 ms
8,588 KB
testcase_20 AC 117 ms
8,572 KB
testcase_21 AC 72 ms
8,560 KB
testcase_22 RE -
testcase_23 AC 1,622 ms
8,684 KB
testcase_24 AC 406 ms
8,872 KB
testcase_25 AC 156 ms
8,712 KB
testcase_26 AC 94 ms
8,708 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

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


n = int(input())
a = [int(input()) for _ in range(n)]
count = [0]*n
for v in (a):
    count[v] += 1
M = 10**9+7
ans = 0
dp = [0]*(n+1)
dp[0] = 1
for k in range(n):
    v = count[k]
    if v==0:
        continue
    ndp = [0]*(n+1)
    for b in range(n):
        val = dp[b]
        if val==0:
            continue
        ndp[b] += val
        ndp[b+1] += v*val%M
        ndp[b] %= M
        ndp[b+1] %= M
    dp = ndp
g = [1]
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