結果

問題 No.107 モンスター
ユーザー zuvizudarzuvizudar
提出日時 2017-12-05 23:21:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,928 bytes
コンパイル時間 1,349 ms
コンパイル使用メモリ 90,848 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-19 04:28:43
合計ジャッジ時間 2,734 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1<<25

typedef long long ll;
//#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int N;
vi a,b,d;
vi dp;
void input(){
	cin>>N;
	d.resize(N+1);
	dp.resize(1<<N,0);
	rep(i,N)cin>>d[i];
}
/*
int ans=0;
int dfs(int S,int now,vi t){
	if(S>=(1<<N)-1){
	//	rep(i,t.size())PP(t[i])
	//	P(now)
		ans=max(ans,now);
		return 0;
	}
	if(dp[S]!=-1)return dp[S];
	int ret=-INF;
	int MAX_HP=100;
	rep(i,N){
		if((S>>i)&1){
			if(d[i]<0){
				MAX_HP+=100;
			}
		}
	}
	rep(i,N){
		if((S>>i)&1)continue;
		t.pb(i);
		int tmp=-INF;
		if(d[i]<0){
			if(now+d[i]>0){
				tmp=dfs(S|1<<i,now+d[i],t)+d[i];
			}
			else 
				tmp=-INF;
		}
		else{
			tmp=dfs(S|1<<i,min(now+d[i],MAX_HP),t)+d[i];
		}
		ret=max(ret,tmp);
		t.pop_back();
	}
	//P(ret)
	return dp[S]=ret;
}*/
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	vi t;
//	dfs(0,100,t);
	dp[0]=100;
	rep(S,1<<N){
		if(dp[S]==0)continue;
		int MAX_HP=100;
		rep(i,N){
			if((S>>i)&1&&d[i]<0)MAX_HP+=100;
		}
		rep(i,N){
			if((S>>i)&1)continue;
			int next=min(MAX_HP,dp[S]+d[i]);
			dp[S+(1<<i)]=max(dp[S+(1<<i)],next);
		}
	}
	P(dp[(1<<N)-1])
	return 0;
}

0