From bd83470bcff80ef15633d119541f0a9a127e6021 Mon Sep 17 00:00:00 2001 From: Minsung_Kang Date: Fri, 22 Mar 2024 00:07:18 +0900 Subject: [PATCH 1/2] =?UTF-8?q?2024-03-22=20=EB=91=90=20=EC=88=98=EC=9D=98?= =?UTF-8?q?=20=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rivkms/Two_pointer/3273.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 rivkms/Two_pointer/3273.cpp diff --git a/rivkms/Two_pointer/3273.cpp b/rivkms/Two_pointer/3273.cpp new file mode 100644 index 0000000..415f456 --- /dev/null +++ b/rivkms/Two_pointer/3273.cpp @@ -0,0 +1,36 @@ +#include +#include +#include + +using namespace std; +int main(){ + int n, goal; + int a, b, cnt = 0;; + cin >> n; + a = 0; + b = n-1; + vector vec(n,0); + for(int i = 0; i> vec[i]; + } + sort(vec.begin(), vec.end()); + cin >> goal; + while(true){ + if(b<=a){ + cout << cnt; + break; + } + if(vec[a]+vec[b] == goal){ + cnt++; + a+=1; + b-=1; + } + else if(vec[a]+vec[b] > goal){ + b-=1; + } + else{ + a+=1; + } + } + return 0; +} \ No newline at end of file From 78ce0b62c1b11157bbe337372ea99c20fe755e38 Mon Sep 17 00:00:00 2001 From: Minsung_Kang Date: Fri, 22 Mar 2024 00:08:57 +0900 Subject: [PATCH 2/2] Update README.md --- rivkms/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rivkms/README.md b/rivkms/README.md index f479664..ce6b0a7 100644 --- a/rivkms/README.md +++ b/rivkms/README.md @@ -4,8 +4,10 @@ |:----:|:---------:|:----:|:-----:|:----:| | 1차시 | 2024.02.12 | DP | [평범한 배낭](https://www.acmicpc.net/problem/12865) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/5) | | 2차시 | 2024.02.15 | Recursion | [하노이 탑 이동 순서](https://www.acmicpc.net/problem/11729) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/8) | -| 3차시 | 2024.02.18 | DP | [하노이 탑 이동 순서](https://www.acmicpc.net/problem/10844) | [#3](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/11) | +| 3차시 | 2024.02.18 | DP | [쉬운 계단 수](https://www.acmicpc.net/problem/10844) | [#3](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/11) | | 4차시 | 2024.02.18 | Backtracking | [N-queen](https://www.acmicpc.net/problem/9663) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/13) | | 5차시 | 2024.02.24 | Backtracking | [입대](https://www.acmicpc.net/problem/31413) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/18) | | 6차시 | 2024.02.27 | BFS | [토마토](https://www.acmicpc.net/problem/7576) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/20) | ---- +| 7차시 | 2024.03.01 | DP | [연속합](https://www.acmicpc.net/problem/1912) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/25) | +| 8차시 | 2024.03.01 | Greedy | [회의실 배정](https://www.acmicpc.net/problem/1931) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/28) | +| 9차시 | 2024.03.22 | two-pointer | [두 수의 합](https://www.acmicpc.net/problem/3273) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/38) | \ No newline at end of file