結果

問題 No.616 へんなソート
ユーザー wajima_wataruwajima_wataru
提出日時 2017-12-29 11:31:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 504 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 11,012 KB
実行使用メモリ 778,312 KB
最終ジャッジ日時 2023-08-23 08:57:06
合計ジャッジ時間 4,938 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 15 ms
7,976 KB
testcase_02 AC 15 ms
7,912 KB
testcase_03 AC 17 ms
8,292 KB
testcase_04 AC 25 ms
9,160 KB
testcase_05 AC 16 ms
7,808 KB
testcase_06 AC 21 ms
8,696 KB
testcase_07 AC 16 ms
7,964 KB
testcase_08 AC 23 ms
8,964 KB
testcase_09 AC 33 ms
10,368 KB
testcase_10 AC 17 ms
8,200 KB
testcase_11 AC 22 ms
9,080 KB
testcase_12 AC 97 ms
20,280 KB
testcase_13 TLE -
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 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
A = input()

if N == 1:
	print(1)
else:
	dp = [[0 for i in range(N * (N - 1))] for j in range(N + 1)]
	cum = [[] for _ in range(N + 1)]
	dp[1][0] = 1
	cum[1] = [0, 1, 1]
	j_max = 2
	for i in range(2, N + 1):
		sum_val = 0
		cum[i].append(0)
		for j in range(min(j_max, K + 1)):
			dp[i][j] = cum[i - 1][j + 1] - cum[i - 1][max(0, j - i + 1)]
			sum_val += dp[i][j]
			cum[i].append(sum_val)
		j_max += i
		cum[i] += [sum_val] * i
	print(sum(dp[N][0:K + 1]) % 1000000007)
0