結果
問題 | No.37 遊園地のアトラクション |
ユーザー | htensai |
提出日時 | 2019-12-07 10:37:40 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,001 bytes |
コンパイル時間 | 3,642 ms |
コンパイル使用メモリ | 73,180 KB |
実行使用メモリ | 58,396 KB |
最終ジャッジ日時 | 2023-08-26 04:45:56 |
合計ジャッジ時間 | 9,236 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 114 ms
55,936 KB |
testcase_02 | AC | 142 ms
56,068 KB |
testcase_03 | WA | - |
testcase_04 | AC | 144 ms
55,960 KB |
testcase_05 | AC | 147 ms
56,344 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 123 ms
55,748 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 109 ms
55,924 KB |
testcase_26 | AC | 112 ms
55,784 KB |
testcase_27 | AC | 143 ms
56,076 KB |
testcase_28 | AC | 118 ms
55,888 KB |
testcase_29 | WA | - |
testcase_30 | AC | 116 ms
55,704 KB |
ソースコード
import java.util.*; public class Main { static int t; static int n; static int[] tArr; static int[] vArr; static int[][] dp; public static void main (String[] args) { Scanner sc = new Scanner(System.in); t = sc.nextInt(); n = sc.nextInt(); tArr = new int[n + 1]; for (int i = 1; i <= n; i++) { tArr[i] = sc.nextInt(); } vArr = new int[n + 1]; for (int i = 1; i <= n; i++) { vArr[i] = sc.nextInt(); } dp = new int[n + 1][t + 1]; System.out.println(dfw(n, t)); } static int dfw(int idx, int time) { if (idx == 0) { return 0; } if (dp[idx][time] != 0) { return dp[idx][time]; } int value = vArr[idx]; int total = 0; for (int i = 0; i * tArr[idx] <= time && value > 0; i++) { dp[idx][time] = Math.max(dp[idx][time], total + dfw(idx - 1, time - i * tArr[idx])); total += value; value /= 2; } return dp[idx][time]; } }