結果
問題 |
No.107 モンスター
|
ユーザー |
![]() |
提出日時 | 2017-01-17 14:12:54 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 844 bytes |
コンパイル時間 | 551 ms |
コンパイル使用メモリ | 62,092 KB |
実行使用メモリ | 7,936 KB |
最終ジャッジ日時 | 2024-12-23 00:47:38 |
合計ジャッジ時間 | 1,645 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 WA * 1 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <string> using namespace std; typedef long long ll; #define max2(a,b) a=max(a,b) int bitDP[1 << 16][18]; int main() { int n; cin >> n; vector<int>D(n); for (int i = 0; i < n; i++)cin >> D[i]; bitDP[0][1] = 100; for (int i = 0; i < (1 << n); i++) { for (int j = 1; j <= n; j++) { if (bitDP[i][j] == 0)continue;//へんじがない、ただのしかばねのようだ for (int k = 0; k < n; k++) { if ((i & (1 << k)) == 0) { if (D[k] > 0) { max2(bitDP[i | (1 << k)][j], min(j * 100, bitDP[i][j] + D[k])); } else { max2(bitDP[i | (1 << k)][j + 1], max(0, bitDP[i][j] + D[k])); } } } } } int ans = 0; for (int j = 1; j < n + 1; j++) { max2(ans, bitDP[(1 << n) - 1][j]); } cout << ans << endl; return 0; }