結果

問題 No.269 見栄っ張りの募金活動
ユーザー htensaihtensai
提出日時 2020-01-09 15:36:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,010 ms / 5,000 ms
コード長 1,235 bytes
コンパイル時間 2,175 ms
コンパイル使用メモリ 76,900 KB
実行使用メモリ 50,080 KB
最終ジャッジ日時 2024-05-02 13:46:16
合計ジャッジ時間 11,179 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
36,724 KB
testcase_01 AC 52 ms
36,912 KB
testcase_02 AC 51 ms
36,916 KB
testcase_03 AC 94 ms
38,400 KB
testcase_04 AC 1,420 ms
42,084 KB
testcase_05 AC 57 ms
36,668 KB
testcase_06 AC 52 ms
36,648 KB
testcase_07 AC 2,010 ms
50,080 KB
testcase_08 AC 53 ms
36,664 KB
testcase_09 AC 52 ms
36,788 KB
testcase_10 AC 52 ms
36,968 KB
testcase_11 AC 723 ms
39,096 KB
testcase_12 AC 51 ms
36,696 KB
testcase_13 AC 386 ms
39,568 KB
testcase_14 AC 55 ms
37,052 KB
testcase_15 AC 546 ms
40,324 KB
testcase_16 AC 52 ms
36,708 KB
testcase_17 AC 53 ms
36,584 KB
testcase_18 AC 554 ms
41,232 KB
testcase_19 AC 228 ms
39,208 KB
testcase_20 AC 160 ms
38,696 KB
testcase_21 AC 149 ms
38,420 KB
testcase_22 AC 196 ms
38,804 KB
testcase_23 AC 86 ms
37,812 KB
testcase_24 AC 301 ms
39,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] first = br.readLine().split(" ", 3);
        int n = Integer.parseInt(first[0]);
        int s = Integer.parseInt(first[1]);
        int kk = Integer.parseInt(first[2]);
        int total = s - n * (n - 1) / 2 * kk;
       if (total < 0) {
            System.out.println(0);
            return;
        }
        int[][] dp = new int[n + 1][total + 1];
        dp[0][0] = 1;
        for (int i = 1; i < n; i++) {
            for (int j = 0; j <= total; j++) {
                if (dp[i - 1][j] == 0) {
                    continue;
                }
                for (int k = 0; k * (n - i + 1) + j <= total; k++) {
                    int value = k * (n - i + 1) + j;
                    dp[i][value] += dp[i - 1][j];
                    dp[i][value] %= MOD;
                }
            }
        }
        int sum = 0;
        for (int i = 0; i <= total; i++ ) {
            sum += dp[n - 1][i];
            sum %= MOD;
        }
        System.out.println(sum);
    }
}
0