Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 373 Bytes

3273.md

File metadata and controls

29 lines (23 loc) · 373 Bytes

3273

Python

import sys
input = sys.stdin.readline

N = int(input())
lst = list(map(int, input().split()))
lst.sort()
x = int(input())

ans = 0
start = 0
end = N-1
while start < end:
    val = lst[start] + lst[end]
    if val == x:
        ans += 1
        start += 1
    elif val > x:
        end -= 1
    elif val < x:
        start += 1

print(ans)