結果

問題 No.107 モンスター
ユーザー tkzw_21tkzw_21
提出日時 2014-12-20 16:10:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 73,652 KB
実行使用メモリ 12,884 KB
最終ジャッジ日時 2023-09-02 20:08:01
合計ジャッジ時間 1,735 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
11,560 KB
testcase_01 AC 3 ms
11,596 KB
testcase_02 AC 4 ms
11,556 KB
testcase_03 AC 3 ms
11,848 KB
testcase_04 AC 3 ms
11,612 KB
testcase_05 AC 3 ms
11,600 KB
testcase_06 AC 3 ms
11,556 KB
testcase_07 AC 3 ms
11,604 KB
testcase_08 AC 3 ms
11,604 KB
testcase_09 AC 3 ms
11,660 KB
testcase_10 AC 3 ms
11,732 KB
testcase_11 AC 3 ms
11,548 KB
testcase_12 WA -
testcase_13 AC 4 ms
11,860 KB
testcase_14 AC 6 ms
12,120 KB
testcase_15 AC 6 ms
12,240 KB
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

int dp[20][1<<16+1];

int main(void){
	int n;
	cin >> n;
	vector<int> d(n);
	for(int i=0;i<n;i++)
		cin >> d[i];
	for(int i=0;i<20;i++)for(int j=0;j<(1<<n);j++)dp[i][j] = -INF;

	dp[0][0] = 100;
	for(int i=0;i<20;i++){
		for(int j=0;j<(1<<n);j++){
			if(dp[i][j] <= 0)continue;
			for(int k=0;k<n;k++){
				if(j&(1<<k))continue;
				if(d[k] < 0)
					dp[i+1][j|(1<<k)] = min((i+1)*100,dp[i][j] + d[k]);
				else
					dp[i][j|(1<<k)] = min((i+1)*100,dp[i][j] + d[k]);
			}
		}
	}

	int ret =0;
	for(int i=0;i<20;i++){
		// cout << dp[i][(1<<n)-1] << endl;
		ret = max(dp[i][(1<<n)-1],ret);
	}
	cout << max(0,ret) << endl;
	return 0;
}
0