結果

問題 No.1011 Infinite Stairs
ユーザー htensaihtensai
提出日時 2020-05-13 13:31:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 489 ms / 2,000 ms
コード長 708 bytes
コンパイル時間 2,232 ms
コンパイル使用メモリ 74,320 KB
実行使用メモリ 178,600 KB
最終ジャッジ日時 2023-09-24 11:15:31
合計ジャッジ時間 8,780 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,864 KB
testcase_01 AC 125 ms
55,876 KB
testcase_02 AC 169 ms
58,708 KB
testcase_03 AC 391 ms
128,616 KB
testcase_04 AC 189 ms
68,092 KB
testcase_05 AC 489 ms
178,600 KB
testcase_06 AC 122 ms
55,968 KB
testcase_07 AC 165 ms
56,280 KB
testcase_08 AC 123 ms
56,032 KB
testcase_09 AC 124 ms
56,072 KB
testcase_10 AC 170 ms
55,912 KB
testcase_11 AC 191 ms
67,932 KB
testcase_12 AC 166 ms
56,568 KB
testcase_13 AC 173 ms
64,780 KB
testcase_14 AC 132 ms
55,996 KB
testcase_15 AC 183 ms
68,424 KB
testcase_16 AC 319 ms
108,320 KB
testcase_17 AC 156 ms
60,568 KB
testcase_18 AC 253 ms
86,216 KB
testcase_19 AC 152 ms
56,068 KB
testcase_20 AC 134 ms
55,524 KB
testcase_21 AC 190 ms
67,684 KB
testcase_22 AC 222 ms
78,128 KB
testcase_23 AC 192 ms
67,720 KB
testcase_24 AC 199 ms
68,072 KB
testcase_25 AC 227 ms
78,152 KB
testcase_26 AC 157 ms
60,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int k = sc.nextInt();
		int[][] dp = new int[n + 1][k + 2];
		dp[0][0] = 1;
		for (int i = 1; i <= n; i++) {
		    for (int j = 0; j < k; j++) {
		        dp[i][j + 1] += dp[i - 1][j];
		        dp[i][j + 1] %= MOD;
		        dp[i][Math.min(j + d + 1, k + 1)] += MOD - dp[i - 1][j];
		        dp[i][Math.min(j + d + 1, k + 1)] %= MOD;
		    }
		    for (int j = i; j <= k + 1; j++) {
		        dp[i][j] += dp[i][j - 1];
		        dp[i][j] %= MOD;
		    }
		}
		System.out.println(dp[n][k]);
	}
}
0