結果

問題 No.107 モンスター
ユーザー IL_mstaIL_msta
提出日時 2015-07-29 21:14:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,376 bytes
コンパイル時間 964 ms
コンパイル使用メモリ 84,860 KB
実行使用メモリ 7,560 KB
最終ジャッジ日時 2023-09-24 21:59:50
合計ジャッジ時間 3,797 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 48 ms
4,564 KB
testcase_14 AC 114 ms
4,376 KB
testcase_15 AC 114 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 21 ms
4,376 KB
testcase_18 AC 249 ms
4,460 KB
testcase_19 AC 251 ms
4,596 KB
testcase_20 AC 57 ms
4,376 KB
testcase_21 AC 54 ms
4,376 KB
testcase_22 AC 115 ms
5,624 KB
testcase_23 AC 285 ms
7,560 KB
testcase_24 AC 261 ms
5,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
//#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
 
/////////
#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 PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
int dp[1<<16][16];
int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(16);//
	
	int N;
	cin>>N;
	int D[16];
	rep(i,N){
		cin>>D[i];
	}
	dp[0][0] = 100;
	for(int t=0;t<N;++t){//Nターン繰り返す
		for(int i=0; i<N; ++i){
			for(int k=(1<<N)-2;k>=0;--k){
				for(int Lv=0;Lv<N;++Lv){
					if( ( (1<<i) & k ) == 0 && dp[k][Lv] > 0 ){
						if(D[i] > 0){
							if( (Lv+1)*100 < dp[k][Lv] + D[i] ){
								dp[(1<<i)|k][Lv] = (Lv+1)*100;
							}else{
								dp[(1<<i)|k][Lv] = max(dp[(1<<i)|k][Lv], dp[k][Lv]+D[i]);
							}
						}else{
							if( dp[k][Lv] + D[i] > 0){
								dp[(1<<i)|k][Lv+1] = max(dp[(1<<i)|k][Lv+1], dp[k][Lv]+D[i] ) ;
							}
						}
					}
				}
			}
		}
	}
	int ans = 0;
	for(int i=0;i<N;++i){
		ans = max(ans,dp[(1<<N)-1][i]);
	}
	P(ans);
	return 0;
}
0