結果

問題 No.107 モンスター
ユーザー tkzw_21tkzw_21
提出日時 2014-12-20 15:49:12
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 723 bytes
コンパイル時間 818 ms
コンパイル使用メモリ 73,848 KB
実行使用メモリ 8,360 KB
最終ジャッジ日時 2023-09-02 20:07:13
合計ジャッジ時間 7,733 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 2 ms
4,368 KB
testcase_10 AC 2 ms
4,368 KB
testcase_11 AC 2 ms
4,372 KB
testcase_12 AC 2 ms
4,368 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <map>
#include <cstring>
#include <algorithm>

using namespace std;

int dp[1<<16+1];
vector<int> d;
int n;

int dfs(long long bit){
	int ret=-114514;
	int cnt = 1;
	for(int i=0;i<n;i++)if(!(bit&1<<i) && d[i]<0)cnt++;

	if(dp[bit] != -1)return dp[bit];
	if((1<<n)-1 == bit)return 100;

	for(int i=0;i<n;i++){
		if(!(bit&(1<<i))){
			ret = max(ret,dfs(bit|(1<<i))+d[i]);
		}
	}
	ret = min(cnt*100,ret);

	if(ret <= 0)return -114514;
	return dp[bit]=ret;
}

int main(void){
	cin >> n;
	d.resize(n);
	for(int i=0;i<n;i++)
		cin >> d[i];
	memset(dp,-1,sizeof(dp));
	int hp = 100;
	
	cout << max(0,dfs(0)) << endl;

	return 0;
}
0