638. 大礼包_动态规划

# encoding=utf-8

class Solution(object):
    def judge(self, special, needs):
        for i in range(len(needs)):
            if special[i] > needs[i]:
                return False  # 题目要求不能超出待购物品的数量。

        return True

    def shoppingOffers(self, price, special, needs):
        """
        :type price: List[int]
        :type special: List[List[int]]
        :type needs: List[int]
        :rtype: int
        """

        res = 0

        for i in range(len(needs)):
            res += price[i] * needs[i]

        for i in range(len(special)):
            if self.judge(special[i], needs):
                new_needs = []

                for j in range(len(needs)):
                    new_needs.append(needs[j] - special[i][j])

                curr_cost = self.shoppingOffers(price, special, new_needs) + special[i][-1]

                res = min(res, curr_cost)

        return res

# print Solution().shoppingOffers([2, 5], [[3, 0, 5], [1, 2, 10]], [3, 2])

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
behavir_2c = behavir_2b['道具ID'] ic_libao_idh = ic_libaoh1[ic_libaoh1['道具ID'].isin(behavir_2c)]['package_id'] bigR_user_pac = bigR_user[bigR_user['package_id'].isin(ic_libao_idh)][['package_id']] ic_libao_idh1 = pd.merge(bigR_user_pac,ic_libaoh1,how = 'left',on = 'package_id') ic_libao_idha = ic_libao_idh1[ic_libao_idh1['道具ID'].isin(behavir_2c)].groupby('道具ID').sum().sort_values(by='道具数量',ascending=False) ic_libao_idhb = ic_libao_idha[['道具数量','道具美元']].reset_index() behavir_libaoh = pd.merge(behavir_2b,ic_libao_idhb,how = 'left',on = '道具ID').fillna(0) behavir_libaoh = pd.merge(behavir_libaoh,behavir_add_pay,how = 'left',on = '道具ID').fillna(0) behavir_libaoh = pd.merge(behavir_libaoh,behavir_add_notpay,how = 'left',on = '道具ID').fillna(0) behavir_libaoh = pd.merge(behavir_libaoh,ic_daoju_gems,how = 'left',on = '道具ID').fillna(0) behavir_libaoh['礼包道具钻石'] = behavir_libaoh['道具数量']*behavir_libaoh['道具原价'] behavir_libaoh['add_count_pay_zuan'] = behavir_libaoh['add_count_pay']*behavir_libaoh['道具原价'] behavir_libaoh['add_count_notpay_zuan'] = behavir_libaoh['add_count_notpay']*behavir_libaoh['道具原价'] behavir_libaohh = behavir_libaoh.groupby('item_class').sum().sort_values(by='add_count_pay_zuan',ascending=False).reset_index() behavir_libaohh1 = behavir_libaohh.rename(columns={'item_class': '道具类别'}) ic_daojua = behavir_libaohh1[['道具类别','del_count','道具消耗钻石','道具数量','道具美元','add_count_pay','add_count_notpay','礼包道具钻石','add_count_pay_zuan','add_count_notpay_zuan']]
07-15

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值