結果

問題 No.616 へんなソート
ユーザー ayaoniayaoni
提出日時 2020-12-30 22:12:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 419 ms / 2,000 ms
コード長 965 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 82,164 KB
実行使用メモリ 250,496 KB
最終ジャッジ日時 2024-04-16 22:39:30
合計ジャッジ時間 3,578 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,096 KB
testcase_01 AC 37 ms
52,352 KB
testcase_02 AC 38 ms
52,608 KB
testcase_03 AC 44 ms
60,032 KB
testcase_04 AC 45 ms
60,800 KB
testcase_05 AC 37 ms
52,096 KB
testcase_06 AC 47 ms
60,288 KB
testcase_07 AC 47 ms
59,776 KB
testcase_08 AC 48 ms
61,312 KB
testcase_09 AC 52 ms
62,080 KB
testcase_10 AC 44 ms
59,648 KB
testcase_11 AC 45 ms
60,416 KB
testcase_12 AC 54 ms
64,640 KB
testcase_13 AC 177 ms
135,680 KB
testcase_14 AC 53 ms
64,384 KB
testcase_15 AC 42 ms
59,648 KB
testcase_16 AC 45 ms
60,928 KB
testcase_17 AC 124 ms
109,568 KB
testcase_18 AC 59 ms
67,584 KB
testcase_19 AC 59 ms
69,248 KB
testcase_20 AC 44 ms
60,544 KB
testcase_21 AC 45 ms
60,928 KB
testcase_22 AC 50 ms
62,720 KB
testcase_23 AC 38 ms
52,480 KB
testcase_24 AC 37 ms
52,352 KB
testcase_25 AC 37 ms
52,736 KB
testcase_26 AC 38 ms
52,480 KB
testcase_27 AC 38 ms
52,480 KB
testcase_28 AC 419 ms
250,496 KB
testcase_29 AC 415 ms
250,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import permutations,accumulate
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,K = MI()
A = LI()
mod = 10**9+7

dp = [[0]*(K+1) for _ in range(N+1)]
for j in range(K+1):
    dp[0][j] = 1
for i in range(1,N+1):
    for j in range(K+1):
        if j >= i:
            dp[i][j] = dp[i-1][j]-dp[i-1][j-i]
        else:
            dp[i][j] = dp[i-1][j]
    X = [0]*(K+1)
    for j in range(K+1):
        if j == 0:
            X[j] = dp[i][j]
        else:
            X[j] = X[j-1]+dp[i][j]
            X[j] %= mod
    dp[i] = X

print(dp[-1][-1])
0