λ¬Έμ
https://www.acmicpc.net/problem/3273
νμ΄
# λ°±μ€ 3273λ² λ¬Έμ - λ μμ ν©
n = int(input())
a = sorted(list(map(int, input().split())))
x = int(input())
answer = 0
left, right = 0, n-1
while left < right:
temp = a[left] + a[right]
if temp == x:
answer += 1
left += 1
elif temp < x:
left += 1
else:
right -= 1
print(answer)
ν¬ ν¬μΈν°λ₯Ό μ¬μ©νμ¬ νμλ€.
'ποΈ Algorithm > π© λ°±μ€' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
π© [λ°±μ€] [Python] 16234λ²_μΈκ΅¬ μ΄λ (0) | 2022.12.16 |
---|---|
π© [λ°±μ€] [Python] 2589λ²_보물 νμ (0) | 2022.12.14 |
π© [λ°±μ€] [Python] [Class5] 2467λ²_μ©μ‘ (0) | 2022.12.08 |
π© [λ°±μ€] [Python] 3184λ²_μ (0) | 2022.12.07 |
π© [λ°±μ€] [Python] 1743λ²_μμλ¬Ό νΌνκΈ° (0) | 2022.12.07 |