1940번: 주몽 (acmicpc.net)

##
#sorting #Two_pointer
투 포인터 문제로 [l, r] → [l+1, r] or [l, r-1] or [l+1, r-1] 의 경우입니다. 
먼저 받아온 배열을 정렬합니다. i를 시작에, j를 끝에 두고 만약에 l[i], l[j]의 합이 M보다 작은 경우에는 i를 1 더하고, M보다 큰 경우에는 j를 1 빼고, M과 같은 경우에는 i, j를 둘다 1씩 더하고, count 합니다. 반복문 안에서 i, j가 같거나 뒤바뀌는 경우에는 break 합니다. 
시간복잡도는 정렬과 반복문으로 인해서 O(nlogn +n), O(nlogn)입니다.

활동지에 작성한내용 그대로

##
import sys
input = sys.stdin.read
inp = list(map(lambda x:x.replace('\x1a',''),input().splitlines()))

N = int(inp[0])
M = int(inp[1])
l = list(map(int,inp[2].split()))
l.sort()

i = 0
j = N-1
count = 0
while(True):
    if (i>=j):
        break

    if l[i] + l[j] < M:
        i += 1
    elif l[i] + l[j] > M:
        j -= 1
    else:
        count += 1
        i+=1
        j-=1
print(count)