We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 25ce73d commit 948661bCopy full SHA for 948661b
Hongjoo/백준/블랙프라이데이.py
@@ -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
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
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