結果

問題 No.3046 yukicoderの過去問
ユーザー tentententen
提出日時 2021-02-12 09:44:02
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 760 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 71,312 KB
実行使用メモリ 56,100 KB
最終ジャッジ日時 2023-09-26 09:12:55
合計ジャッジ時間 8,541 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,672 KB
testcase_01 AC 124 ms
54,040 KB
testcase_02 AC 124 ms
55,552 KB
testcase_03 AC 142 ms
55,900 KB
testcase_04 AC 127 ms
55,812 KB
testcase_05 AC 136 ms
56,100 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
権限があれば一括ダウンロードができます

ソースコード

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 k = sc.nextInt();
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int max = n;
        int[] dp = new int[k + 1];
        dp[0] = 1;
        for (int i = 0; i < k; i++) {
            for (int j = 0; j < max; j++) {
                if (i + arr[j] > k) {
                    max = j;
                    break;
                }
                dp[i + arr[j]] += dp[i];
                dp[i + arr[j]] %= MOD;
            }
        }
        System.out.println(dp[k]);
    }
}
0