結果

問題 No.616 へんなソート
ユーザー 双六
提出日時 2020-07-26 17:45:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 438 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 248,064 KB
最終ジャッジ日時 2024-06-28 18:55:42
合計ジャッジ時間 3,775 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K = getlist()
	DP = [0] * (N ** 2 + N + 1)
	DP[0] = 1
	for i in range(1, N):
		DPs = [0] * (N ** 2 + N + 2)
		for j in range(1, N ** 2 + N + 2):
			DPs[j] = (DPs[j - 1] + DP[j - 1]) % con
		# print(DPs)
		for j in range(N ** 2 + N, -1, -1):
			if j - i >= 0:
				DP[j] = DPs[j + 1] - DPs[j - i]
			else:
				DP[j] = DPs[j + 1]
		# print(DP)

	# print(DP)
	ans = 0
	for i in range(K + 1):
		ans += DP[i]
		ans %= con

	print(ans)
	




if __name__ == '__main__':
	main()
0