python 拼多多抢券

您所在的位置:网站首页 爬虫抢优惠券 python 拼多多抢券

python 拼多多抢券

2023-08-27 12:54| 来源: 网络整理| 查看: 265

思路就是从价值最高的优惠券开始遍历尝试,价值相同的优惠券则先尝试需要满足的金额小的,然后用在比满减所需金额大的商品中最便宜的那个上,就ok

from sys import stdin as f

[n,m] = [int(i) for i in f.readline().split()]

price = sorted([int(i) for i in f.readline().split()],reverse=True)

dc = {}

for i in range(m):

[man,jian] = [int(i) for i in f.readline().split()]

if jian in dc:

dc[jian]+=[man]

else:

dc[jian]=[man]

for k,v in dc.items():

dc[k] = sorted(v)

def used():

#    dc = deepcopy(dcc)

num = 0

dc_value = sorted(dc,reverse = True)

while price and dc_value:

dc_max = dc_value[0]

if price[0]

dc.pop(dc_max)

dc_value.pop(0)

continue

#        print(dc)

mv = dc[dc_max].pop(0)

index = 0

while index

if (index



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3