結果

問題 No.107 モンスター
ユーザー kou6839kou6839
提出日時 2015-08-12 15:43:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 5,000 ms
コード長 779 bytes
コンパイル時間 3,113 ms
コンパイル使用メモリ 75,668 KB
実行使用メモリ 56,284 KB
最終ジャッジ日時 2023-08-22 23:05:01
合計ジャッジ時間 6,543 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,644 KB
testcase_01 AC 123 ms
55,424 KB
testcase_02 AC 123 ms
55,856 KB
testcase_03 AC 123 ms
55,832 KB
testcase_04 AC 122 ms
56,176 KB
testcase_05 AC 120 ms
55,384 KB
testcase_06 AC 123 ms
55,892 KB
testcase_07 AC 122 ms
55,996 KB
testcase_08 AC 124 ms
55,536 KB
testcase_09 AC 127 ms
55,972 KB
testcase_10 AC 124 ms
56,040 KB
testcase_11 AC 126 ms
55,988 KB
testcase_12 AC 125 ms
56,088 KB
testcase_13 AC 148 ms
56,284 KB
testcase_14 AC 139 ms
55,820 KB
testcase_15 AC 143 ms
55,676 KB
testcase_16 AC 124 ms
55,920 KB
testcase_17 AC 132 ms
55,764 KB
testcase_18 AC 142 ms
55,876 KB
testcase_19 AC 135 ms
55,668 KB
testcase_20 AC 139 ms
55,484 KB
testcase_21 AC 144 ms
56,120 KB
testcase_22 AC 141 ms
55,644 KB
testcase_23 AC 151 ms
56,124 KB
testcase_24 AC 142 ms
56,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.awt.Frame;
import java.net.StandardSocketOptions;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] D = new int[N];
		for(int i=0;i<N;i++) D[i]=sc.nextInt();
		int[] dp = new int[1<<N];
		Arrays.fill(dp,-100000000);
		dp[0]=100;
		for(int i=0;i<(1<<N);i++){
			if(dp[i]<0) continue;
			int did = 1;
			for(int j=0;j<N;j++) if( (i&(1<<j))>0. && D[j]<0) did+=1;
			for(int j=0;j<N;j++){
				if( (i&(1<<j))==0){
					if(D[j]>0){
						dp[i+(1<<j)]=Math.min(did*100, Math.max(dp[i+(1<<j)], dp[i]+D[j]));
					}else if(dp[i]+D[j]>0){
						dp[i+(1<<j)]=Math.max(dp[i+(1<<j)], dp[i]+D[j]);
					}
				}
			}
		}
		System.out.println(Math.max(0, dp[(1<<N)-1]));
		
	}
}
0