Skip to content

Commit 499fe19

Browse files
committed
[BOJ] 좋다 / 골드4 / 45분
https://www.acmicpc.net/problem/1253
1 parent e56f179 commit 499fe19

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
N = int(input())
2+
arr = list(map(int, input().split()))
3+
4+
arr_sorted = sorted(arr)
5+
6+
answer = 0
7+
8+
for i in range(N):
9+
start = 0
10+
end = len(arr_sorted) - 1
11+
12+
while start < end:
13+
if arr_sorted[start] + arr_sorted[end] == arr_sorted[i]:
14+
if start == i:
15+
start += 1
16+
elif end == i:
17+
end -= 1
18+
else:
19+
answer += 1
20+
break
21+
elif arr_sorted[start] + arr_sorted[end] > arr_sorted[i]:
22+
end -= 1
23+
else:
24+
start += 1
25+
26+
print(answer)

0 commit comments

Comments
 (0)