結果

問題 No.243 出席番号(2)
ユーザー 👑 rin204rin204
提出日時 2022-11-03 00:00:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 476 bytes
コンパイル時間 66 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 13,156 KB
最終ジャッジ日時 2023-09-24 10:52:08
合計ジャッジ時間 16,842 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
12,372 KB
testcase_01 AC 15 ms
7,776 KB
testcase_02 AC 15 ms
7,936 KB
testcase_03 AC 109 ms
7,784 KB
testcase_04 AC 48 ms
7,908 KB
testcase_05 AC 33 ms
7,792 KB
testcase_06 AC 28 ms
7,752 KB
testcase_07 AC 73 ms
7,928 KB
testcase_08 AC 357 ms
8,340 KB
testcase_09 AC 123 ms
8,172 KB
testcase_10 AC 67 ms
7,912 KB
testcase_11 AC 47 ms
7,832 KB
testcase_12 AC 430 ms
8,336 KB
testcase_13 AC 854 ms
8,344 KB
testcase_14 AC 277 ms
8,300 KB
testcase_15 AC 126 ms
8,328 KB
testcase_16 AC 74 ms
8,392 KB
testcase_17 AC 1,229 ms
8,424 KB
testcase_18 AC 1,519 ms
8,356 KB
testcase_19 AC 435 ms
8,444 KB
testcase_20 AC 210 ms
8,424 KB
testcase_21 AC 133 ms
8,404 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 AC 706 ms
8,356 KB
testcase_25 AC 301 ms
8,520 KB
testcase_26 AC 176 ms
8,344 KB
testcase_27 TLE -
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())
    if a >= n:
        continue
    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