結果
| 問題 |
No.107 モンスター
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2014-12-19 00:25:19 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,820 bytes |
| コンパイル時間 | 2,570 ms |
| コンパイル使用メモリ | 115,820 KB |
| 実行使用メモリ | 36,996 KB |
| 最終ジャッジ日時 | 2024-06-12 01:28:04 |
| 合計ジャッジ時間 | 4,306 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 6 WA * 15 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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));}
}
kuuso1