結果

問題 No.243 出席番号(2)
ユーザー mkawa2mkawa2
提出日時 2023-02-24 11:42:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 448 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 10,980 KB
実行使用メモリ 15,608 KB
最終ジャッジ日時 2023-10-10 21:53:34
合計ジャッジ時間 14,617 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
15,608 KB
testcase_01 AC 19 ms
8,580 KB
testcase_02 AC 19 ms
8,532 KB
testcase_03 AC 139 ms
8,696 KB
testcase_04 AC 56 ms
8,704 KB
testcase_05 AC 40 ms
8,584 KB
testcase_06 AC 34 ms
8,628 KB
testcase_07 RE -
testcase_08 AC 454 ms
8,632 KB
testcase_09 AC 158 ms
8,588 KB
testcase_10 AC 85 ms
8,752 KB
testcase_11 AC 60 ms
8,756 KB
testcase_12 RE -
testcase_13 AC 1,034 ms
8,752 KB
testcase_14 AC 328 ms
8,668 KB
testcase_15 AC 156 ms
8,692 KB
testcase_16 AC 91 ms
8,700 KB
testcase_17 RE -
testcase_18 AC 1,906 ms
8,612 KB
testcase_19 AC 555 ms
8,664 KB
testcase_20 AC 281 ms
8,636 KB
testcase_21 AC 157 ms
8,680 KB
testcase_22 RE -
testcase_23 TLE -
testcase_24 AC 966 ms
8,708 KB
testcase_25 AC 376 ms
8,756 KB
testcase_26 AC 213 ms
8,628 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

md = 10**9+7

from array import array

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

dp = array("Q", [1]+[0]*n)
for a in range(n):
    if cnt[a] == 0: continue
    for i in range(n)[::-1]:
        dp[i+1] += dp[i]*cnt[a]%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