結果

問題 No.107 モンスター
ユーザー kosakkunkosakkun
提出日時 2017-01-10 18:42:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,719 bytes
コンパイル時間 1,087 ms
コンパイル使用メモリ 93,812 KB
実行使用メモリ 4,644 KB
最終ジャッジ日時 2023-08-22 22:00:07
合計ジャッジ時間 1,927 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

ll dp[1<<16];
ll hp[1<<16];

int main(){
    
    int N; cin>>N;
    vector<int> D(N);
    REP(i,N)cin>>D[i];
    
    REP(i,(1<<16))dp[i]=hp[i]=-1e9;
    
    dp[(1<<N)-1]=100;
    hp[(1<<N)-1]=100;
    
    for (int i=((1<<N)-1); i>=0; i-- ){
        for (int j=0; j<N; j++ ) {
            int mask = (1<<j);
            int add = D[j];
            if( (i|mask) > i ) {
                if ( add>0 ) {
                    dp[i] = max(dp[i],min(dp[i|mask]+add,hp[i|mask]));
                    hp[i] = hp[i|mask];
                }else{
                    if ( dp[i|mask] + add>0 ) {
                        if ( hp[i|mask] >= hp[i] ) {
                            dp[i] = dp[i|mask] + add;
                            hp[i] = hp[i|mask] + 100;
                        }
                    }
                }
            }
        }
    }
    
    if(dp[0]<0)cout<<0<<endl;
    else cout<<dp[0]<<endl;
    
    return 0;
}
0