python的,有没有大佬帮我看看为什么有几个点过不了,谢谢了
查看原帖
python的,有没有大佬帮我看看为什么有几个点过不了,谢谢了
1231862
lzysxfcs楼主2024/4/7 14:34

def f(): n, m = map(int, input().split()) prices = [int(input()) for _ in range(m)] # 每个农夫愿意支付的价格 prices.sort() max_profit = 0 #最大利润 for index,price in enumerate(prices): profit=price*(len(prices)-index) #当前利润 if profit > max_profit: max_profit = profit a=price #最大利润时的单价 print(a,max_profit) f()

2024/4/7 14:34
加载中...