結果
問題 | No.1701 half price |
ユーザー | みーすけ |
提出日時 | 2021-10-08 23:46:33 |
言語 | Java21 (openjdk 21) |
結果 |
MLE
|
実行時間 | - |
コード長 | 929 bytes |
コンパイル時間 | 2,397 ms |
コンパイル使用メモリ | 73,608 KB |
実行使用メモリ | 683,596 KB |
最終ジャッジ日時 | 2023-09-30 14:11:24 |
合計ジャッジ時間 | 6,560 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 119 ms
56,616 KB |
testcase_01 | AC | 120 ms
55,776 KB |
testcase_02 | MLE | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 119 ms
55,584 KB |
testcase_06 | RE | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | RE | - |
testcase_10 | AC | 119 ms
55,916 KB |
testcase_11 | WA | - |
testcase_12 | AC | 120 ms
55,940 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 120 ms
56,160 KB |
testcase_16 | AC | 120 ms
56,024 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 118 ms
56,064 KB |
testcase_21 | AC | 123 ms
56,220 KB |
ソースコード
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int w = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } int[][] dp = new int[n + 1][w + 1]; int[][] dp2 = new int[n + 1][w + 1]; dp[0][0] = 1; for (int i = 0; i < n; i++) { for (int j = 0; j <= w; j++) { dp[i + 1][j] += dp[i][j]; dp2[i + 1][j] += dp2[i][j]; if (j >= a[i]){ dp[i + 1][j] += dp[i][j - a[i]]; dp2[i + 1][j] += dp2[i][j - a[i]]; } if (j >= a[i] / 2){ dp2[i + 1][j] += dp[i][j - a[i] / 2]; } } } System.out.println(dp[n][w]+dp2[n][w]); } }