結果

問題 No.269 見栄っ張りの募金活動
ユーザー GrenacheGrenache
提出日時 2015-08-22 00:06:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 934 bytes
コンパイル時間 3,329 ms
コンパイル使用メモリ 74,392 KB
実行使用メモリ 64,800 KB
最終ジャッジ日時 2023-09-23 01:07:18
合計ジャッジ時間 7,358 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
56,180 KB
testcase_01 AC 118 ms
56,316 KB
testcase_02 AC 116 ms
55,976 KB
testcase_03 AC 119 ms
55,856 KB
testcase_04 AC 134 ms
58,488 KB
testcase_05 AC 117 ms
56,300 KB
testcase_06 AC 119 ms
56,140 KB
testcase_07 AC 135 ms
64,800 KB
testcase_08 AC 117 ms
56,340 KB
testcase_09 AC 119 ms
56,112 KB
testcase_10 AC 116 ms
56,224 KB
testcase_11 AC 128 ms
56,480 KB
testcase_12 AC 117 ms
56,488 KB
testcase_13 AC 126 ms
56,168 KB
testcase_14 AC 118 ms
56,232 KB
testcase_15 AC 130 ms
56,384 KB
testcase_16 AC 117 ms
56,224 KB
testcase_17 AC 118 ms
56,208 KB
testcase_18 AC 128 ms
58,240 KB
testcase_19 AC 126 ms
56,248 KB
testcase_20 AC 120 ms
55,960 KB
testcase_21 AC 118 ms
56,440 KB
testcase_22 AC 127 ms
56,168 KB
testcase_23 AC 122 ms
56,120 KB
testcase_24 AC 121 ms
55,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder269 {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int MOD = 1_000_000_007;
        int n = sc.nextInt();
        int s = sc.nextInt();
        int k = sc.nextInt();

        if (s < k * n * (n - 1) / 2) {
        	System.out.println("0");
        } else {
        	int m = s - k * n * (n - 1) / 2;
        	int[][] dp = new int[n + 1][m + 1];
        	dp[0][0] = 1;
        	for (int i = 1; i <= n; i++) {
        		for (int j = 0; j <= m; j++) {
        			if (j - i >= 0) {
        				dp[i][j] = (dp[i][j - i] + dp[i - 1][j]) % MOD;
        			} else {
        				dp[i][j] = dp[i - 1][j];
        			}
        		}
        	}

        	int ret = 0;
//        	for (int i = 1; i <= n; i++) {
        		ret = (ret + dp[n][m]) % MOD;
//        	}
        	System.out.println(ret);
        }

        sc.close();
    }
}
0