結果

問題 No.269 見栄っ張りの募金活動
ユーザー tentententen
提出日時 2020-12-23 12:35:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,907 ms / 5,000 ms
コード長 814 bytes
コンパイル時間 2,272 ms
コンパイル使用メモリ 74,384 KB
実行使用メモリ 64,468 KB
最終ジャッジ日時 2023-10-21 15:08:30
合計ジャッジ時間 15,475 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
57,340 KB
testcase_01 AC 137 ms
57,596 KB
testcase_02 AC 135 ms
57,332 KB
testcase_03 AC 153 ms
57,668 KB
testcase_04 AC 2,102 ms
61,836 KB
testcase_05 AC 147 ms
57,344 KB
testcase_06 AC 133 ms
57,596 KB
testcase_07 AC 2,907 ms
64,468 KB
testcase_08 AC 132 ms
57,452 KB
testcase_09 AC 173 ms
61,840 KB
testcase_10 AC 135 ms
57,340 KB
testcase_11 AC 893 ms
57,364 KB
testcase_12 AC 149 ms
59,676 KB
testcase_13 AC 544 ms
57,504 KB
testcase_14 AC 352 ms
57,344 KB
testcase_15 AC 720 ms
57,344 KB
testcase_16 AC 171 ms
59,416 KB
testcase_17 AC 144 ms
55,676 KB
testcase_18 AC 859 ms
61,924 KB
testcase_19 AC 323 ms
59,424 KB
testcase_20 AC 255 ms
57,504 KB
testcase_21 AC 484 ms
57,436 KB
testcase_22 AC 270 ms
57,408 KB
testcase_23 AC 161 ms
57,564 KB
testcase_24 AC 501 ms
57,672 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 s = sc.nextInt();
        int k = sc.nextInt();
        int[][] dp = new int[n][s + 1];
        for (int i = 0; i * n <= s; i++) {
            dp[0][i * n]++;
        }
        for (int i = 1; i < n; i++) {
            for (int j = 0; j <= s; j++) {
                if (dp[i - 1][j] == 0) {
                    continue;
                }
                for (int a = k; j + a * (n - i) <= s; a++) {
                    dp[i][j + a * (n - i)] += dp[i - 1][j];
                    dp[i][j + a * (n - i)] %= MOD;
                }
            }
        }
        System.out.println(dp[n - 1][s]);
    }
}
0