結果

問題 No.243 出席番号(2)
ユーザー 👑 rin204rin204
提出日時 2022-11-02 23:58:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 444 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 12,980 KB
最終ジャッジ日時 2023-09-24 10:51:01
合計ジャッジ時間 12,524 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,880 KB
testcase_01 AC 15 ms
7,824 KB
testcase_02 AC 15 ms
7,772 KB
testcase_03 AC 109 ms
7,852 KB
testcase_04 AC 47 ms
7,824 KB
testcase_05 AC 33 ms
7,912 KB
testcase_06 AC 28 ms
7,748 KB
testcase_07 WA -
testcase_08 AC 363 ms
8,292 KB
testcase_09 AC 122 ms
8,256 KB
testcase_10 AC 66 ms
7,908 KB
testcase_11 AC 48 ms
7,916 KB
testcase_12 WA -
testcase_13 AC 818 ms
8,432 KB
testcase_14 AC 272 ms
8,272 KB
testcase_15 AC 125 ms
8,244 KB
testcase_16 AC 75 ms
8,200 KB
testcase_17 TLE -
testcase_18 AC 1,493 ms
8,480 KB
testcase_19 AC 432 ms
8,380 KB
testcase_20 AC 226 ms
8,428 KB
testcase_21 AC 128 ms
8,340 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

n = int(input())
cnt = {}
for _ in range(n):
    a = int(input())
    cnt[a] = cnt.get(a, 0) + 1
dp = [0] * (n + 1)
dp[0] = 1

for v in cnt.values():
    for i in range(n, 0, -1):
        dp[i] += dp[i - 1] * v
        dp[i] %= MOD

fact = [1]
for i in range(1, n + 1):
    fact.append(fact[-1] * i % MOD)

ans = 0
pm = 1
for i, d in enumerate(dp):
    ans += pm * d * fact[n - i] % MOD
    pm *= -1
    ans %= MOD
print(ans)
0