結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,720 KB
testcase_01 AC 19 ms
8,644 KB
testcase_02 AC 20 ms
8,664 KB
testcase_03 AC 135 ms
8,724 KB
testcase_04 AC 56 ms
8,648 KB
testcase_05 AC 40 ms
8,648 KB
testcase_06 AC 34 ms
8,544 KB
testcase_07 RE -
testcase_08 AC 468 ms
8,680 KB
testcase_09 AC 164 ms
8,616 KB
testcase_10 AC 84 ms
8,576 KB
testcase_11 AC 59 ms
8,608 KB
testcase_12 RE -
testcase_13 AC 1,016 ms
8,584 KB
testcase_14 AC 334 ms
8,696 KB
testcase_15 AC 156 ms
8,748 KB
testcase_16 AC 91 ms
8,592 KB
testcase_17 RE -
testcase_18 AC 1,800 ms
8,788 KB
testcase_19 AC 558 ms
8,720 KB
testcase_20 AC 262 ms
8,656 KB
testcase_21 AC 160 ms
8,660 KB
testcase_22 RE -
testcase_23 TLE -
testcase_24 AC 904 ms
8,856 KB
testcase_25 AC 381 ms
8,628 KB
testcase_26 AC 219 ms
8,836 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("L", [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