python的,有没有大佬帮我看看为什么有几个点过不了,谢谢了

P2637 第一次,第二次,成交!

在洛谷上写python不友好啊,没有额外的时空限制
by qian_feng @ 2024-04-07 15:01:25


@[qian_feng](/user/1234973) Python 跑 $1000$ 还是能过去的。。。 没有超时/超空间就不要说这个。
by Terrible @ 2024-04-07 15:22:24


@[lzysxfcs](/user/1231862) 点击回帖栏上面的 `</>` 并选择 Python 可以插入代码。 你这个代码没有用到 $n$,怎么可能是对的。
by Terrible @ 2024-04-07 15:23:00


```python def f(): n, m = map(int, input().split()) prices = [int(input()) for _ in range(m)] # 每个农夫愿意支付的价格 prices=sorted(prices)[-n:] m=min(m,n) max_profit = 0 best_price = 0 for i in range(m): price = prices[i] current_profit = price * (m - i) if current_profit > max_profit: max_profit = current_profit best_price = price print(best_price, max_profit) f() ```
by Terrible @ 2024-04-07 15:27:28


@[Terrible](/user/195942) 好的,谢谢明白了
by lzysxfcs @ 2024-04-07 21:07:20


|