参考:https://blog.csdn.net/weixin_45697774/article/details/105563993
题目:https://leetcode.cn/problems/maximum-total-reward-using-operations-ii/description/
class Solution {
public:
int maxTotalReward(vector<int>& rewardValues) {
bitset<100000>f;
f[0]=1;
sort(rewardValues.begin(),rewardValues.end());
rewardValues.erase(unique(rewardValues.begin(),rewardValues.end()),rewardValues.end());
for(const auto &x:rewardValues){
int l=f.size()-x;
f|=f<<l>>l<<x;
}
for(int i=f.size();i>=0;i--){
if(f[i]==1){
return i;
}
}
return 0;
}
};