Skip to content

Commit 948661b

Browse files
committed
[BOJ]#18114.블랙프라이데이/골드5/힌트
https://www.acmicpc.net/problem/18114
1 parent 25ce73d commit 948661b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import sys
2+
3+
N, target = map(int , sys.stdin.readline().split())
4+
li = sorted(list(map(int, sys.stdin.readline().split())))
5+
6+
7+
# 최대 3개
8+
# 1개
9+
def check_fit():
10+
if target in li :
11+
return 1
12+
else : # 2개, 3개 , 안됨
13+
left= 0; right = N-1
14+
while left < right :
15+
if target == sum([li[left],li[right]]) :
16+
return 1
17+
elif target > sum([li[left],li[right]]):
18+
diff = target - sum([li[left],li[right]])
19+
if diff in li and diff !=li[left] and diff != li[right] :
20+
return 1
21+
else :
22+
left += 1
23+
else : # target < sum
24+
right -= 1
25+
# 3개 조합
26+
return 0
27+
28+
print(check_fit())

0 commit comments

Comments
 (0)