結果

問題 No.243 出席番号(2)
ユーザー titiatitia
提出日時 2022-08-09 03:42:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 477 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 11,800 KB
実行使用メモリ 22,780 KB
最終ジャッジ日時 2023-10-19 15:19:39
合計ジャッジ時間 13,131 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
17,936 KB
testcase_01 AC 92 ms
17,800 KB
testcase_02 AC 89 ms
17,800 KB
testcase_03 AC 201 ms
17,848 KB
testcase_04 AC 122 ms
17,840 KB
testcase_05 AC 109 ms
17,836 KB
testcase_06 AC 104 ms
17,840 KB
testcase_07 AC 151 ms
18,092 KB
testcase_08 AC 471 ms
17,896 KB
testcase_09 AC 209 ms
17,908 KB
testcase_10 AC 158 ms
17,884 KB
testcase_11 AC 131 ms
17,884 KB
testcase_12 AC 584 ms
18,164 KB
testcase_13 AC 986 ms
18,096 KB
testcase_14 AC 382 ms
17,936 KB
testcase_15 AC 214 ms
17,928 KB
testcase_16 AC 153 ms
17,936 KB
testcase_17 AC 1,505 ms
18,324 KB
testcase_18 AC 1,792 ms
18,220 KB
testcase_19 AC 562 ms
17,980 KB
testcase_20 AC 318 ms
18,192 KB
testcase_21 AC 220 ms
18,180 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 c in C:
    if c<N:
        v=C[c]
        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