結果
| 問題 | No.37 遊園地のアトラクション |
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-03-03 01:34:52 |
| 言語 | C++11(old_compat) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 76 ms / 5,000 ms |
| コード長 | 702 bytes |
| 記録 | |
| コンパイル時間 | 1,095 ms |
| コンパイル使用メモリ | 170,744 KB |
| 実行使用メモリ | 23,316 KB |
| 最終ジャッジ日時 | 2026-03-08 16:01:50 |
| 合計ジャッジ時間 | 2,960 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int memo[10010][500];
int func(int t, int k, vector<int>& v, vector<int>& c)
{
int& res=memo[t][k];
if (res) return res;
res=0;
for(int i=k;i<v.size();++i) if (t>=c[i])
res=max(res, func(t-c[i], i+1, v, c)+v[i]);
return res;
}
int main()
{
int t, n;
while (cin>>t>>n) {
vector<int> c(n), v(n);
for(int& x: c) cin>>x;
for(int& x: v) cin>>x;
for(int i=0;i<n;++i) {
int x=v[i], y=c[i];
while (x/=2) { v.push_back(x); c.push_back(y); }
}
memset(memo, 0, sizeof(memo));
cout<<func(t, 0, v, c)<<endl;
}
}
hogeover30