結果

問題 No.107 モンスター
ユーザー codershifth
提出日時 2015-08-11 01:10:17
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 1,181 bytes
コンパイル時間 1,378 ms
コンパイル使用メモリ 162,784 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-18 06:36:29
合計ジャッジ時間 8,040 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 TLE * 1 -- * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()

using namespace std;


class Monster {
public:
    void solve(void) {
            int N;
            cin>>N;
            vector<int> D(N);
            REP(i,N)
                cin>>D[i];
            sort(RANGE(D));

            int res = 0;
            do {
                int HP = 100;
                int maxHP = 100;
                REP(i,N)
                {
                    if (D[i] > 0)
                        HP = min(maxHP, HP+D[i]);
                    else
                    {
                        HP += D[i];
                        maxHP += 100;
                    }
                    if (HP <= 0)
                        break;
                }
                res = max(res, HP);
            } while (next_permutation(RANGE(D)));

            cout<<res<<endl;
    }
};

#if 1
int main(int argc, char *argv[])
{
        ios::sync_with_stdio(false);
        auto obj = new Monster();
        obj->solve();
        delete obj;
        return 0;
}
#endif
0