結果

問題 No.243 出席番号(2)
ユーザー titiatitia
提出日時 2022-08-09 03:34:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 447 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 11,960 KB
実行使用メモリ 22,440 KB
最終ジャッジ日時 2023-10-19 15:12:07
合計ジャッジ時間 15,850 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
22,440 KB
testcase_01 AC 91 ms
18,092 KB
testcase_02 AC 91 ms
18,092 KB
testcase_03 AC 198 ms
17,904 KB
testcase_04 AC 132 ms
17,896 KB
testcase_05 AC 109 ms
17,896 KB
testcase_06 AC 104 ms
17,900 KB
testcase_07 WA -
testcase_08 AC 495 ms
17,984 KB
testcase_09 AC 225 ms
17,952 KB
testcase_10 AC 151 ms
17,940 KB
testcase_11 AC 130 ms
17,940 KB
testcase_12 WA -
testcase_13 AC 988 ms
18,316 KB
testcase_14 AC 395 ms
18,020 KB
testcase_15 AC 228 ms
18,012 KB
testcase_16 AC 163 ms
18,020 KB
testcase_17 TLE -
testcase_18 AC 1,910 ms
18,412 KB
testcase_19 AC 591 ms
18,028 KB
testcase_20 AC 322 ms
18,032 KB
testcase_21 AC 222 ms
18,020 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

N=int(input())
A=[int(input()) for i in range(N)]
C=Counter(A)

mod=10**9+7
FACT=[1]
for i in range(1,2*10**5+1):
    FACT.append(FACT[-1]*i%mod)

DP=[0]*(N+1)
DP[0]=1

for v in C.values():
    for i in range(N-1,-1,-1):
        DP[i+1]+=DP[i]*v
        DP[i+1]%=mod
        

ANS=0

for i in range(N+1):
    x=FACT[N-i]

    if i%2==0:
        ANS+=x*DP[i]
    else:
        ANS-=x*DP[i]

    ANS%=mod

print(ANS)
0