結果

問題 No.107 モンスター
コンテスト
ユーザー kakeyamay
提出日時 2019-07-02 14:37:20
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 3 ms / 5,000 ms
+ 265µs
コード長 486 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,027 ms
コンパイル使用メモリ 214,676 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-10-12 09:12:13
合計ジャッジ時間 3,379 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

int main() {
	
	int N;
	std::cin >> N;
	std::vector<int> D(N);
	for(auto&v:D)std::cin>>v;
	int n = 1<<N;
	std::vector<int> dp(n,0);
	dp[0] = 100;
	for(int x=0;x<n;++x){
		if(dp[x]==0)continue;
		int maxHP = 100;
		for(int i=0;i<N;++i){
			if(x&(1<<i)&&D[i]<0)maxHP+=100;
		}
		for(int i=0;i<N;++i){
			if(x&(1<<i))continue;
			int v=x|(1<<i);
			dp[v]=std::max(dp[v],std::min(dp[x]+D[i],maxHP));
		}
	}
	int ans = dp[n-1];
	std::cout << ans << std::endl;
}
0