結果
| 問題 |
No.37 遊園地のアトラクション
|
| コンテスト | |
| ユーザー |
codershifth
|
| 提出日時 | 2015-07-23 23:56:24 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 5,000 ms |
| コード長 | 1,522 bytes |
| コンパイル時間 | 2,280 ms |
| コンパイル使用メモリ | 170,156 KB |
| 実行使用メモリ | 13,824 KB |
| 最終ジャッジ日時 | 2024-10-10 13:01:06 |
| 合計ジャッジ時間 | 3,210 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()
using namespace std;
class AmusementParkAttraction {
public:
void solve(void) {
int T,N;
cin>>T>>N;
vector<int> C(N);
REP(i,N)
cin>>C[i];
vector<int> V(N);
REP(i,N)
cin>>V[i];
vector<pair<int,int>> V2;
REP(i,N)
{
int v = V[i];
while (v > 0)
{
V2.emplace_back(C[i],v);
v /= 2;
}
}
// V2.size() <= 15*log2(500) <= 135
// 後は通常どおり DP
N = V2.size();
vector<vector<ll>> dp(N+1, vector<ll>(T+1,0));
REP(i,N)
REP(t,T+1)
{
int c,v;
tie(c,v) = V2[i];
if (c <= t)
dp[i+1][t-c] = max(dp[i+1][t-c], dp[i][t]+v);
dp[i+1][t] = max(dp[i+1][t], dp[i][t]);
}
ll res = 0;
REP(t,T+1)
res = max(res,dp[N][t]);
cout<<res<<endl;
}
};
#if 1
int main(int argc, char *argv[])
{
ios::sync_with_stdio(false);
auto obj = new AmusementParkAttraction();
obj->solve();
delete obj;
return 0;
}
#endif
codershifth