結果

問題 No.107 モンスター
ユーザー kuuso1kuuso1
提出日時 2014-12-19 00:25:19
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,820 bytes
コンパイル時間 3,666 ms
コンパイル使用メモリ 107,124 KB
実行使用メモリ 32,160 KB
最終ジャッジ日時 2023-09-02 19:02:26
合計ジャッジ時間 6,528 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
22,744 KB
testcase_01 WA -
testcase_02 AC 58 ms
22,752 KB
testcase_03 WA -
testcase_04 AC 57 ms
20,728 KB
testcase_05 AC 57 ms
22,676 KB
testcase_06 AC 57 ms
20,600 KB
testcase_07 AC 57 ms
22,628 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 63 ms
20,668 KB
testcase_14 AC 61 ms
24,796 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[][] dp=new int[1<<N][];
		for(int i=0;i<(1<<N);i++){
			dp[i]=new int[N+1];
		}
		
		for(int i=0;i<N;i++){
			if(D[i]>0){
				dp[1<<i][1]=100;
			}
			if(D[i]<0 && D[i]+100>0){
				dp[1<<i][1]=100+D[i];
			}
		}
		
		mask=0;
		for(int i=0;i<N;i++){
			if(D[i]<0)mask|=(1<<i);
		}
		
		int ns,nv;
		for(int i=1;i<N;i++){
			for(int s=1;s<(1<<N);s++){
				if(dp[s][i]==0)continue;
				for(int j=0;j<N;j++){
					if((s&(1<<j))==0){
						ns=s|(1<<j);
						if(D[j]>0){
							nv=Math.Min(dp[s][j]+D[j],maxHP(s));
							dp[ns][i+1]=Math.Max(dp[ns][i+1],nv);
						}
						if(D[j]>0 && D[j]+dp[s][j]>0){
							nv=D[j]+dp[s][j];
							dp[ns][i+1]=Math.Max(dp[ns][i+1],nv);
						}
					}
				}
			}
//for(int ii=0;ii<(1<<N);ii++)Console.Write("{0} ",dp[ii][i+1]);Console.WriteLine();
		}
		
		Console.WriteLine(dp[(1<<N)-1][N]);
		
		
		
	}
	
	int mask;
	int maxHP(int state){
		int ret=100;
		state&=mask;
		for(int i=0;i<N;i++){
			if((state&(1<<i))>0)ret+=100;
		}
		return ret;
	}
	
	
	int N;
	int[] D;
	public Sol(){
		N=ri();
		D=ria();
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0