結果

問題 No.37 遊園地のアトラクション
ユーザー htensaihtensai
提出日時 2019-12-07 10:29:09
言語 Java21
(openjdk 21)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 988 bytes
コンパイル時間 2,558 ms
コンパイル使用メモリ 76,904 KB
実行使用メモリ 47,120 KB
最終ジャッジ日時 2024-04-18 20:12:24
合計ジャッジ時間 13,597 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 148 ms
41,580 KB
testcase_01 AC 138 ms
41,276 KB
testcase_02 AC 173 ms
41,424 KB
testcase_03 AC 177 ms
41,732 KB
testcase_04 AC 157 ms
41,288 KB
testcase_05 AC 182 ms
41,212 KB
testcase_06 AC 176 ms
41,696 KB
testcase_07 AC 347 ms
41,940 KB
testcase_08 AC 160 ms
41,432 KB
testcase_09 AC 132 ms
41,296 KB
testcase_10 AC 288 ms
41,784 KB
testcase_11 AC 265 ms
41,760 KB
testcase_12 AC 167 ms
41,636 KB
testcase_13 AC 185 ms
41,500 KB
testcase_14 AC 144 ms
41,624 KB
testcase_15 AC 132 ms
41,348 KB
testcase_16 AC 200 ms
41,668 KB
testcase_17 AC 145 ms
41,540 KB
testcase_18 AC 264 ms
41,844 KB
testcase_19 AC 129 ms
41,412 KB
testcase_20 AC 180 ms
41,488 KB
testcase_21 AC 157 ms
41,348 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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];
   }
}

0