No.37 遊園地のアトラクション - yukicoder
- アトラクション i を訪れるたびに満足度が半減するのをどう表現するか。
- v[i]/2^k, C[i] のアトラクションがあると考える。
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;
}
}
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;
}
};