結果

問題 No.243 出席番号(2)
ユーザー mkawa2mkawa2
提出日時 2023-02-24 11:50:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 395 ms / 2,000 ms
コード長 479 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 29,896 KB
最終ジャッジ日時 2023-10-10 21:53:45
合計ジャッジ時間 7,503 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
29,604 KB
testcase_01 AC 137 ms
29,744 KB
testcase_02 AC 139 ms
29,404 KB
testcase_03 AC 151 ms
29,600 KB
testcase_04 AC 147 ms
29,576 KB
testcase_05 AC 144 ms
29,292 KB
testcase_06 AC 145 ms
29,812 KB
testcase_07 AC 142 ms
29,400 KB
testcase_08 AC 164 ms
29,408 KB
testcase_09 AC 150 ms
29,400 KB
testcase_10 AC 146 ms
29,256 KB
testcase_11 AC 144 ms
29,432 KB
testcase_12 AC 167 ms
29,412 KB
testcase_13 AC 189 ms
29,304 KB
testcase_14 AC 162 ms
29,656 KB
testcase_15 AC 152 ms
29,432 KB
testcase_16 AC 150 ms
29,556 KB
testcase_17 AC 212 ms
29,320 KB
testcase_18 AC 222 ms
29,664 KB
testcase_19 AC 172 ms
29,564 KB
testcase_20 AC 155 ms
29,676 KB
testcase_21 AC 151 ms
29,628 KB
testcase_22 AC 289 ms
29,652 KB
testcase_23 AC 258 ms
29,896 KB
testcase_24 AC 187 ms
29,840 KB
testcase_25 AC 164 ms
29,612 KB
testcase_26 AC 160 ms
29,848 KB
testcase_27 AC 395 ms
29,680 KB
testcase_28 AC 140 ms
29,716 KB
testcase_29 AC 136 ms
29,272 KB
testcase_30 AC 133 ms
29,412 KB
testcase_31 AC 135 ms
29,776 KB
testcase_32 AC 135 ms
29,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

md = 10**9+7

from array import array
import numpy as np

n = int(input())
cnt = array("I", [0]*n)
for _ in range(n):
    a = int(input())
    if a >= n: continue
    cnt[a] += 1

dp = np.zeros(n+1, "i8")
dp[0] = 1
for a in range(n):
    if cnt[a] == 0: continue
    dp[1:n+1] += dp[:n]*cnt[a]
    dp %= md

ans = 0
f = 1
for i in range(n+1)[::-1]:
    cur = dp[i]*f%md
    if i & 1:
        ans -= cur
    else:
        ans += cur
    ans %= md
    f = f*(n+1-i)%md

print(ans)
0