13 條題解

  • 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
    标签
    (無)
    遞交數
    668
    已通過
    220
    上傳者