結果

問題 No.243 出席番号(2)
ユーザー mkawa2mkawa2
提出日時 2023-02-24 11:43:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 470 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 13,044 KB
最終ジャッジ日時 2023-10-10 21:53:36
合計ジャッジ時間 12,165 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
13,024 KB
testcase_01 AC 19 ms
8,520 KB
testcase_02 AC 19 ms
8,660 KB
testcase_03 AC 179 ms
8,588 KB
testcase_04 AC 76 ms
8,600 KB
testcase_05 AC 48 ms
8,592 KB
testcase_06 AC 38 ms
8,548 KB
testcase_07 RE -
testcase_08 AC 665 ms
8,572 KB
testcase_09 AC 224 ms
8,596 KB
testcase_10 AC 114 ms
8,704 KB
testcase_11 AC 75 ms
8,632 KB
testcase_12 RE -
testcase_13 AC 1,483 ms
8,684 KB
testcase_14 AC 463 ms
8,572 KB
testcase_15 AC 220 ms
8,764 KB
testcase_16 AC 122 ms
8,692 KB
testcase_17 RE -
testcase_18 TLE -
testcase_19 AC 804 ms
8,628 KB
testcase_20 AC 376 ms
8,600 KB
testcase_21 AC 213 ms
8,676 KB
testcase_22 RE -
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
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
        dp[i+1] %= 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