11 条题解

  • 0
    @ 2025-10-16 22:35:41
    s = int(input())
    for _ in range(s):
        w, n =map(int,input().split())
        num = list(map(int,input().split()))
        num.sort()
        count = n
        left = 0
        right = n-1
        while left < right:
            if num[left]+num[right]<=w:
                count -= 1
                left+=1
                right-=1
            else:
                right-=1
        print(count)
    

    双指针

    信息

    ID
    148
    时间
    3000ms
    内存
    128MiB
    难度
    6
    标签
    (无)
    递交数
    563
    已通过
    187
    上传者