結果
問題 | No.1621 Sequence Inversions |
ユーザー | mkawa2 |
提出日時 | 2021-07-23 00:01:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,133 ms / 3,000 ms |
コード長 | 1,622 bytes |
コンパイル時間 | 195 ms |
コンパイル使用メモリ | 82,380 KB |
実行使用メモリ | 299,588 KB |
最終ジャッジ日時 | 2024-07-17 21:21:04 |
合計ジャッジ時間 | 26,393 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 787 ms
298,432 KB |
testcase_01 | AC | 762 ms
298,368 KB |
testcase_02 | AC | 761 ms
298,956 KB |
testcase_03 | AC | 771 ms
298,248 KB |
testcase_04 | AC | 767 ms
298,624 KB |
testcase_05 | AC | 759 ms
298,692 KB |
testcase_06 | AC | 755 ms
298,496 KB |
testcase_07 | AC | 765 ms
299,008 KB |
testcase_08 | AC | 1,006 ms
298,952 KB |
testcase_09 | AC | 768 ms
299,184 KB |
testcase_10 | AC | 766 ms
299,380 KB |
testcase_11 | AC | 1,015 ms
299,136 KB |
testcase_12 | AC | 1,133 ms
298,880 KB |
testcase_13 | AC | 1,051 ms
299,588 KB |
testcase_14 | AC | 828 ms
298,844 KB |
testcase_15 | AC | 795 ms
298,820 KB |
testcase_16 | AC | 854 ms
299,008 KB |
testcase_17 | AC | 943 ms
298,964 KB |
testcase_18 | AC | 854 ms
298,920 KB |
testcase_19 | AC | 774 ms
299,136 KB |
testcase_20 | AC | 800 ms
298,880 KB |
testcase_21 | AC | 974 ms
298,944 KB |
testcase_22 | AC | 813 ms
299,136 KB |
testcase_23 | AC | 957 ms
299,092 KB |
testcase_24 | AC | 763 ms
298,240 KB |
testcase_25 | AC | 773 ms
298,492 KB |
testcase_26 | AC | 793 ms
298,740 KB |
testcase_27 | AC | 758 ms
298,612 KB |
testcase_28 | AC | 762 ms
298,304 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 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 if diff>i*c:break dp[nj] += pre*dd[diff][c][i]%md dp[nj] %= md pa = a # p2D(dp) print(dp[k])