結果

問題 No.37 遊園地のアトラクション
ユーザー 37zigen37zigen
提出日時 2016-03-25 19:08:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 152 ms / 5,000 ms
コード長 723 bytes
コンパイル時間 2,154 ms
コンパイル使用メモリ 77,388 KB
実行使用メモリ 41,840 KB
最終ジャッジ日時 2024-04-18 19:49:34
合計ジャッジ時間 7,739 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,524 KB
testcase_01 AC 128 ms
41,468 KB
testcase_02 AC 146 ms
41,584 KB
testcase_03 AC 143 ms
41,796 KB
testcase_04 AC 133 ms
40,536 KB
testcase_05 AC 146 ms
41,640 KB
testcase_06 AC 129 ms
40,800 KB
testcase_07 AC 135 ms
41,416 KB
testcase_08 AC 133 ms
41,168 KB
testcase_09 AC 131 ms
41,472 KB
testcase_10 AC 148 ms
41,432 KB
testcase_11 AC 147 ms
41,400 KB
testcase_12 AC 130 ms
40,756 KB
testcase_13 AC 144 ms
41,492 KB
testcase_14 AC 152 ms
41,840 KB
testcase_15 AC 131 ms
40,748 KB
testcase_16 AC 142 ms
41,576 KB
testcase_17 AC 145 ms
41,468 KB
testcase_18 AC 151 ms
41,568 KB
testcase_19 AC 130 ms
41,460 KB
testcase_20 AC 144 ms
41,596 KB
testcase_21 AC 150 ms
41,496 KB
testcase_22 AC 146 ms
41,656 KB
testcase_23 AC 127 ms
41,280 KB
testcase_24 AC 127 ms
41,484 KB
testcase_25 AC 128 ms
40,984 KB
testcase_26 AC 129 ms
41,148 KB
testcase_27 AC 145 ms
41,452 KB
testcase_28 AC 128 ms
41,404 KB
testcase_29 AC 131 ms
41,432 KB
testcase_30 AC 126 ms
41,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder037;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		int n=sc.nextInt();
		int[] c=new int[n];//アトラクションに乗るのにかかる時間	
		int[] 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();
		}
		solve(t,c,v);

	}
	public static void solve(int t,int[] c,int[] v){
		int[] dp=new int[t+1];
		for(int i=0;i<c.length;i++){
			int cur=v[i];
			while(cur>0){
				for(int j=dp.length-1;j>=c[i];j--){
					dp[j]=Math.max(dp[j], dp[j-c[i]]+cur);
				}
				cur/=2;
			}
		}
		System.out.println(dp[t]);
	}

}
0