結果

問題 No.107 モンスター
ユーザー 古寺いろは古寺いろは
提出日時 2015-04-09 20:04:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 550 bytes
コンパイル時間 1,204 ms
コンパイル使用メモリ 144,980 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-17 19:05:15
合計ジャッジ時間 2,485 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

int dp[1 << 16];

int main(){
	int N;
	cin >> N;
	vector<int> D(N);
	for (int i = 0; i < N; i++)
	{
		cin >> D[i];
	}
	dp[0] = 100;
	for (int i = 0; i < (1 << N); i++)
	{
		if (dp[i] == 0) continue;
		int maxHP = 100;
		for (int j = 0; j < N; j++)
		{
			if ((i >> j) % 2 == 1 && D[j] < 0) maxHP += 100;
		}
		for (int j = 0; j < N; j++)
		{
			if ((i >> j) % 2 == 1) continue;
			int next = dp[i] + D[j];
			dp[i + (1 << j)] = max(dp[i + (1 << j)], next);
		}
	}
	cout << dp[(1 << N) - 1] << endl;
}


0