結果

問題 No.37 遊園地のアトラクション
ユーザー kou6839kou6839
提出日時 2014-12-09 16:19:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 149 ms / 5,000 ms
コード長 814 bytes
コンパイル時間 2,083 ms
コンパイル使用メモリ 77,004 KB
実行使用メモリ 54,560 KB
最終ジャッジ日時 2024-04-18 19:29:01
合計ジャッジ時間 7,303 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
53,432 KB
testcase_01 AC 118 ms
52,884 KB
testcase_02 AC 141 ms
54,012 KB
testcase_03 AC 137 ms
54,132 KB
testcase_04 AC 131 ms
53,852 KB
testcase_05 AC 131 ms
53,192 KB
testcase_06 AC 128 ms
53,140 KB
testcase_07 AC 130 ms
53,284 KB
testcase_08 AC 131 ms
53,936 KB
testcase_09 AC 126 ms
54,304 KB
testcase_10 AC 145 ms
54,228 KB
testcase_11 AC 148 ms
54,560 KB
testcase_12 AC 143 ms
54,336 KB
testcase_13 AC 144 ms
54,112 KB
testcase_14 AC 129 ms
54,088 KB
testcase_15 AC 143 ms
54,116 KB
testcase_16 AC 141 ms
54,168 KB
testcase_17 AC 143 ms
54,092 KB
testcase_18 AC 144 ms
54,004 KB
testcase_19 AC 128 ms
54,204 KB
testcase_20 AC 130 ms
53,296 KB
testcase_21 AC 149 ms
54,064 KB
testcase_22 AC 140 ms
54,120 KB
testcase_23 AC 126 ms
53,852 KB
testcase_24 AC 129 ms
53,916 KB
testcase_25 AC 127 ms
53,984 KB
testcase_26 AC 115 ms
52,932 KB
testcase_27 AC 143 ms
53,944 KB
testcase_28 AC 127 ms
54,200 KB
testcase_29 AC 133 ms
54,176 KB
testcase_30 AC 115 ms
53,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;
 
public class Main {
	static int n;
	static int[] c;
	static int[] v;
	static int[] dp;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t=sc.nextInt();
        n = sc.nextInt();
        dp=new int[t+1];
        c=new int[n];
        v=new int[n];
        for(int i=0;i<n;i++){
        	c[i]=sc.nextInt();
        }
        for(int i=0;i<n;i++){
        	v[i]=sc.nextInt();
        }
        for(int i=0;i<n;i++){
        	int cur = v[i];
        	int count=1;
        	while(cur>0){
        		for(int j=t;j>=c[i]*count;j--){
        			dp[j]=Math.max(dp[j],dp[j-c[i]]+cur);
        		}
        		cur/=2;
        		count++;
        	}
        }

    	System.out.println(dp[t]);
    }
}
0