import os
import sys
w = int(input())
n = int(input())
arr = [0 for i in range(n)]
for i in range(n):
temp = int(input())
arr[i] = temp
# 只是希望分组最少
arr.sort(reverse=True)
left = 0
right = len(arr)-1
ans = 0
while left < right:
ans += 1
if arr[left]+arr[right] <= w:
left += 1
right -= 1
else:
left += 1
if left <= right:
ans += 1
print(ans)
纪念品分组(蓝桥杯-Python)
最新推荐文章于 2024-05-19 19:33:09 发布