結果

問題 No.616 へんなソート
ユーザー tentententen
提出日時 2020-12-25 12:39:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,822 ms / 2,000 ms
コード長 761 bytes
コンパイル時間 2,040 ms
コンパイル使用メモリ 77,440 KB
実行使用メモリ 58,164 KB
最終ジャッジ日時 2023-10-22 04:18:44
合計ジャッジ時間 11,794 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
57,612 KB
testcase_01 AC 117 ms
57,400 KB
testcase_02 AC 118 ms
57,528 KB
testcase_03 AC 118 ms
57,444 KB
testcase_04 AC 127 ms
57,532 KB
testcase_05 AC 105 ms
56,260 KB
testcase_06 AC 134 ms
57,680 KB
testcase_07 AC 119 ms
57,692 KB
testcase_08 AC 132 ms
57,420 KB
testcase_09 AC 131 ms
57,452 KB
testcase_10 AC 122 ms
57,312 KB
testcase_11 AC 138 ms
57,504 KB
testcase_12 AC 166 ms
57,728 KB
testcase_13 AC 735 ms
57,888 KB
testcase_14 AC 156 ms
57,256 KB
testcase_15 AC 119 ms
57,464 KB
testcase_16 AC 135 ms
57,612 KB
testcase_17 AC 463 ms
57,464 KB
testcase_18 AC 162 ms
57,240 KB
testcase_19 AC 194 ms
57,656 KB
testcase_20 AC 142 ms
57,652 KB
testcase_21 AC 137 ms
57,460 KB
testcase_22 AC 161 ms
57,464 KB
testcase_23 AC 117 ms
57,472 KB
testcase_24 AC 119 ms
57,472 KB
testcase_25 AC 119 ms
57,672 KB
testcase_26 AC 117 ms
57,500 KB
testcase_27 AC 120 ms
57,592 KB
testcase_28 AC 1,822 ms
58,164 KB
testcase_29 AC 1,817 ms
58,048 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 k = sc.nextInt();
        int[] dp = new int[k + 1];
        int max = 0;
        dp[0] = 1;
        for (int i = 2; i <= n; i++) {
            for (int j = max; j >= 0; j--) {
                for (int a = 1; a < i && a + j <= k; a++) {
                    dp[a + j] += dp[j];
                    dp[a + j] %= MOD;
                    max = Math.max(max, a + j);
                }
            }
        }
        int ans = 0;
        for (int x : dp) {
            ans += x;
            ans %= MOD;
        }
        System.out.println(ans);
    }
}
0