結果
問題 | No.1621 Sequence Inversions |
ユーザー | mkawa2 |
提出日時 | 2021-07-22 23:50:26 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,592 bytes |
コンパイル時間 | 148 ms |
コンパイル使用メモリ | 82,096 KB |
実行使用メモリ | 305,904 KB |
最終ジャッジ日時 | 2024-07-17 21:12:06 |
合計ジャッジ時間 | 19,109 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 779 ms
305,048 KB |
testcase_01 | AC | 746 ms
298,252 KB |
testcase_02 | AC | 755 ms
299,168 KB |
testcase_03 | AC | 767 ms
298,324 KB |
testcase_04 | AC | 792 ms
298,888 KB |
testcase_05 | AC | 782 ms
298,184 KB |
testcase_06 | AC | 765 ms
298,260 KB |
testcase_07 | AC | 775 ms
298,836 KB |
testcase_08 | AC | 1,022 ms
299,504 KB |
testcase_09 | AC | 773 ms
299,044 KB |
testcase_10 | RE | - |
testcase_11 | AC | 1,060 ms
299,028 KB |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | AC | 1,076 ms
299,020 KB |
testcase_15 | AC | 1,015 ms
299,020 KB |
testcase_16 | TLE | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
ソースコード
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 mx2 = 2505 dd = [[[0]*(mx+1) for _ in range(mx+1)] for _ in range(mx2)] for s in range(mx2): 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])%md 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])