結果
問題 |
No.37 遊園地のアトラクション
|
ユーザー |
![]() |
提出日時 | 2014-11-07 18:07:54 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 681 bytes |
コンパイル時間 | 601 ms |
コンパイル使用メモリ | 57,588 KB |
実行使用メモリ | 646,564 KB |
最終ジャッジ日時 | 2024-12-31 08:31:50 |
合計ジャッジ時間 | 42,854 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 5 WA * 16 TLE * 5 MLE * 1 |
ソースコード
#include <iostream> #include <algorithm> using namespace std; int t, n; int c[22], v[22], dp[10001][1<<15]; int rec(int t, int used){ if(dp[t][used]) return dp[t][used]; int ret = 0; for(int i = 0; i < n; i++){ if(t - c[i] >= 0){ if(used >> i && 1){ int mod = v[i] % 2; v[i] /= 2; ret = max(ret, rec(t - c[i], used) + v[i]); v[i] = v[i] * 2 + mod; } else ret = max(ret, rec(t - c[i], used | (1 << i)) + v[i]); } } return dp[t][used] = ret; } int main(){ cin >> t >> n; for(int i = 0; i < n; i++) cin >> c[i]; for(int i = 0; i < n; i++) cin >> v[i]; cout << rec(t, 0) << endl; }