https://ac.nowcoder.com/acm/problem/14553
题意都是中文的,就不用多说了;
做法:首先一看就能知道是,完全背包问题,但不过他在L到R的技能,但不过,按照普通的思维,肯定是转化为L到R这么多个背包去完全背包,在数据小的时候可以这样做,但不过这道题数据有点大,显然是不可能的。仔细一想对于L到R他有一个蓄力值的加成A和一个基础伤害temp,我们做一个价值分析,如果A的加成大于了temp的平均加成,那么就去R的值,反之就取L的值,我们最后只需要在枚举一下L到R的区间的价值就可以了。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+50;
ll T,v[N],w[N],dp[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
while(cin>>T) {
for(int i=1; i<=3; i++)
cin>>w[i]>>v[i];
ll l,r,tp,A;
cin>>l>>r>>tp>>A;
w[4]=l,v[4]=tp;
w[5]=r,v[5]=tp+A*(r-l);
memset(dp,0,sizeof(dp));
for(int i=1; i<=5; i++) {
for(int j=w[i]; j<=T; j++)
dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
}
for(int i=l; i<=r; i++) {
dp[T]=max(dp[T],dp[T-i]+tp+(i-l)*A);
}
cout<<dp[T]<<endl;
}
return 0;
}