結果

問題 No.107 モンスター
ユーザー codershifthcodershifth
提出日時 2015-08-11 01:10:17
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,181 bytes
コンパイル時間 1,312 ms
コンパイル使用メモリ 149,404 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-09-25 08:01:17
合計ジャッジ時間 8,290 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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