結果
問題 | No.1238 選抜クラス |
ユーザー |
![]() |
提出日時 | 2020-09-25 21:56:21 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 921 ms / 2,000 ms |
コード長 | 1,033 bytes |
コンパイル時間 | 3,194 ms |
コンパイル使用メモリ | 76,476 KB |
実行使用メモリ | 468,244 KB |
最終ジャッジ日時 | 2024-06-28 06:33:30 |
合計ジャッジ時間 | 17,916 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
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; int[][][] dp = new int[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][j2] %= mod; dp[i1][j + 1][j2 + a[i]] += dp[i][j][j2]; dp[i1][j + 1][j2 + a[i]] %= 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); } }