結果

問題 No.107 モンスター
ユーザー IL_mstaIL_msta
提出日時 2015-07-29 21:23:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 158 ms / 5,000 ms
コード長 1,406 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 85,872 KB
実行使用メモリ 7,872 KB
最終ジャッジ日時 2023-08-22 23:02:13
合計ジャッジ時間 3,106 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 28 ms
4,464 KB
testcase_14 AC 66 ms
4,500 KB
testcase_15 AC 66 ms
4,500 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 12 ms
4,376 KB
testcase_18 AC 134 ms
4,732 KB
testcase_19 AC 136 ms
5,072 KB
testcase_20 AC 33 ms
4,476 KB
testcase_21 AC 31 ms
4,496 KB
testcase_22 AC 68 ms
5,792 KB
testcase_23 AC 158 ms
7,872 KB
testcase_24 AC 141 ms
5,312 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][17];
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){
				if( ( (1<<i) & k ) == 0 ){
					for(int Lv=0;Lv<N;++Lv){
						if( 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