結果
問題 |
No.107 モンスター
|
ユーザー |
![]() |
提出日時 | 2015-10-03 14:59:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 617 bytes |
コンパイル時間 | 1,571 ms |
コンパイル使用メモリ | 163,876 KB |
実行使用メモリ | 10,144 KB |
最終ジャッジ日時 | 2024-07-19 19:24:53 |
合計ジャッジ時間 | 8,370 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 9 TLE * 1 -- * 11 |
ソースコード
#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(int i=0; i<(n); i++) int N; int maxhp(vector<int> D, int hp, int ceilhp) { if (D.empty()) return hp; int mh = 0; REP(i,D.size()) { int h = min(hp + D[i], ceilhp); if (h <= 0) continue; // 死亡 vector<int> tmp; for (int j : D) tmp.push_back(j); tmp.erase(tmp.begin() + i); mh = max(mh, maxhp(tmp, h, ceilhp + ((D[i]<0)?100:0))); } return mh; } signed main() { cin >> N; vector<int> D(N); REP(i,N) cin >> D[i]; cout << maxhp(D, 100, 100) << endl; return 0; }