목차

두 수의 합

ps
링크acmicpc.net/…
출처BOJ
문제 번호9024
문제명두 수의 합
레벨골드 5
분류

정렬

시간복잡도O(t*nlogn)
인풋사이즈t<=?, n<=1,000,000
사용한 언어Python
제출기록217040KB / 2852ms
최고기록2628ms
해결날짜2021/09/20

풀이

코드

"""Solution code for "BOJ 9024. 두 수의 합".

- Problem link: https://www.acmicpc.net/problem/9024
- Solution link: http://www.teferi.net/ps/problems/boj/9024

Tags: [Sort]
"""


def main():
    t = int(input())
    for _ in range(t):
        # pylint: disable=unused-variable
        n, K = [int(x) for x in input().split()]
        nums = [int(x) for x in input().split()]

        nums.sort(key=lambda x, k=K: abs(x + x - k))
        sums = [abs(x + y - K) for x, y in zip(nums, nums[1:])]
        print(sums.count(min(sums)))


if __name__ == '__main__':
    main()