From 372f6b00633c9245217525023ffba02048c9e6f0 Mon Sep 17 00:00:00 2001 From: DongGeun974 Date: Thu, 26 May 2022 13:22:24 +0900 Subject: [PATCH] 220526 hdg --- source/HDG/220526/bj2230.md | 31 +++++++++++++++++++++++++++++++ source/HDG/220526/bj2473.md | 33 +++++++++++++++++++++++++++++++++ source/HDG/220526/bj3273.md | 27 +++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 source/HDG/220526/bj2230.md create mode 100644 source/HDG/220526/bj2473.md create mode 100644 source/HDG/220526/bj3273.md diff --git a/source/HDG/220526/bj2230.md b/source/HDG/220526/bj2230.md new file mode 100644 index 0000000..30ef499 --- /dev/null +++ b/source/HDG/220526/bj2230.md @@ -0,0 +1,31 @@ +## 수 고르기 + +답안을 참고했습니다 + +python3 / 34692kb / 224ms + +```python +import sys + +n, m = map(int, sys.stdin.readline().split()) +arr = [] +for i in range(n): + arr.append(int(sys.stdin.readline())) +arr.sort() + +left, right = 0,0 +answer = sys.maxsize + +while left < n and right < n: + temp = arr[right] - arr[left] + if temp == m: + print(m) + exit() + + if temp 0: + end-=1 + else: + break + +print(result[0], result[1], result[2]) +``` diff --git a/source/HDG/220526/bj3273.md b/source/HDG/220526/bj3273.md new file mode 100644 index 0000000..20f0aca --- /dev/null +++ b/source/HDG/220526/bj3273.md @@ -0,0 +1,27 @@ +## 두 수의 합 + +양 끝에 포인터를 설정 한 후 풀었습니다 + +python3 / 41620kb / 132ms + +```python +import sys + +n = int(sys.stdin.readline()) +arr = list(map(int, sys.stdin.readline().split())) +arr.sort() +x = int(sys.stdin.readline()) + +left, right = 0, n-1 +answer = 0 + +while left < right: + if arr[left] + arr[right] == x: + answer +=1 + right-=1 + elif arr[left] + arr[right] > x: + right-=1 + else: + left+=1 +print(answer) +```