結果
問題 |
No.37 遊園地のアトラクション
|
ユーザー |
![]() |
提出日時 | 2019-12-07 10:29:09 |
言語 | Java (openjdk 23) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 988 bytes |
コンパイル時間 | 2,517 ms |
コンパイル使用メモリ | 77,976 KB |
実行使用メモリ | 61,272 KB |
最終ジャッジ日時 | 2024-10-10 13:36:45 |
合計ジャッジ時間 | 13,271 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | AC * 22 TLE * 1 -- * 4 |
ソースコード
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; 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]; } }