結果

問題 No.1238 選抜クラス
ユーザー ks2mks2m
提出日時 2020-09-25 21:53:55
言語 Java
(openjdk 23)
結果
MLE  
実行時間 -
コード長 1,088 bytes
コンパイル時間 2,133 ms
コンパイル使用メモリ 77,152 KB
実行使用メモリ 743,712 KB
最終ジャッジ日時 2024-06-28 06:31:02
合計ジャッジ時間 20,160 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 MLE * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int mod = 1000000007;
		long[][][] dp = new long[n + 1][n + 1][10001];
		dp[0][0][0] = 1;
		for (int i = 0; i < n; i++) {
			int i1 = i + 1;
			for (int j = 0; j <= i; j++) {
				for (int j2 = 0; j2 <= 100 * i; j2++) {
					dp[i1][j][j2] += dp[i][j][j2];
					dp[i1][j + 1][j2 + a[i]] += dp[i][j][j2];
				}
			}
			for (int j = 0; j <= i1; j++) {
				for (int j2 = 0; j2 <= 100 * i1; j2++) {
					dp[i1][j][j2] %= mod;
				}
			}
		}

		long ans = 0;
		for (int j = 1; j <= n; j++) {
			for (int j2 = j * k; j2 <= 10000; j2++) {
				ans += dp[n][j][j2];
			}
		}
		ans %= mod;
		System.out.println(ans);
	}
}
0