結果

問題 No.1621 Sequence Inversions
ユーザー vwxyzvwxyz
提出日時 2022-05-03 10:13:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 782 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 12,996 KB
最終ジャッジ日時 2023-09-15 08:36:43
合計ジャッジ時間 5,031 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
12,996 KB
testcase_01 AC 19 ms
8,632 KB
testcase_02 AC 32 ms
8,652 KB
testcase_03 AC 18 ms
8,608 KB
testcase_04 AC 19 ms
8,644 KB
testcase_05 AC 19 ms
8,584 KB
testcase_06 AC 26 ms
8,560 KB
testcase_07 AC 132 ms
10,112 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import Counter
readline=sys.stdin.readline

N,K=map(int,readline().split())
A=list(map(int,readline().split()))
mod=998244353
C=Counter(A)
DP=[1]
s=0
for a in sorted(list(C.keys())):
    c=C[a]
    dp=[[[0]*(s*c+1) for j in range(c+1)] for i in range(s+1)]
    dp[0][0][0]=1
    for i in range(s+1):
        for j in range(c+1):
            for k in range(s*c+1):
                if i:
                    dp[i][j][k]+=dp[i-1][j][k]
                if j and k-i>=0:
                    dp[i][j][k]+=dp[i][j-1][k-i]
                dp[i][j][k]%=mod
    PREV=DP
    DP=[0]*((s+c)*(s+c-1)//2+1)
    for i in range(s*(s-1)//2+1):
        for j in range(s*c+1):
            DP[i+j]+=PREV[i]*dp[-1][-1][j]
            DP[i+j]%=mod
    s+=c
ans=DP[K]
print(ans)
0