結果
| 問題 |
No.107 モンスター
|
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2017-01-17 14:17:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 5,000 ms |
| コード長 | 846 bytes |
| コンパイル時間 | 489 ms |
| コンパイル使用メモリ | 61,988 KB |
| 実行使用メモリ | 8,064 KB |
| 最終ジャッジ日時 | 2024-12-23 00:47:44 |
| 合計ジャッジ時間 | 1,313 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#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;
}
kurenai3110