結果
問題 | No.1621 Sequence Inversions |
ユーザー | mkawa2 |
提出日時 | 2021-07-22 23:31:36 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,576 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 82,316 KB |
実行使用メモリ | 85,904 KB |
最終ジャッジ日時 | 2024-07-17 20:43:17 |
合計ジャッジ時間 | 4,389 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 94 ms
85,192 KB |
testcase_01 | AC | 96 ms
84,864 KB |
testcase_02 | AC | 104 ms
85,236 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | AC | 97 ms
84,872 KB |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | AC | 112 ms
84,836 KB |
testcase_25 | AC | 103 ms
84,992 KB |
testcase_26 | AC | 97 ms
84,992 KB |
testcase_27 | AC | 97 ms
85,344 KB |
testcase_28 | AC | 97 ms
84,864 KB |
ソースコード
import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**16 md = 998244353 # md = 10**9+7 mx = 100 dd = [[[0]*(mx+1) for _ in range(mx+1)] for _ in range(mx+1)] for s in range(mx+1): for j in range(1, mx+1): for lim in range(mx+1): if j == 1: if s <= lim: dd[s][j][lim] = 1 else: dd[s][j][lim] = 0 elif s == 0: dd[s][j][lim] = 1 elif s > lim*j: dd[s][j][lim] = 0 else: dd[s][j][lim] = dd[s-j][j][lim-1]+dd[s][j-1][lim] from collections import Counter n, k = LI() aa = LI() aa.sort() ac = Counter(aa) dp = [0]*(k+1) dp[0] = 1 pa = -1 for i, a in enumerate(aa): if a == pa: continue dp1 = dp dp = [0]*(k+1) c = ac[a] for j in range(k+1): pre = dp1[j] if pre == 0: continue for nj in range(j, k+1): diff = nj-j dp[nj] += pre*dd[diff][c][i]%md dp[nj] %= md pa = a # p2D(dp) print(dp[k])