From c21c0ac1775a6150c33be5323e2c0216356fef2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=84=B8=EC=A7=84?= Date: Sun, 5 Feb 2023 14:27:32 +0900 Subject: [PATCH 1/4] =?UTF-8?q?2170/=20=EA=B3=A8=EB=93=9C5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sejinpark/Sweeping/2170.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/sejinpark/Sweeping/2170.cpp diff --git a/src/sejinpark/Sweeping/2170.cpp b/src/sejinpark/Sweeping/2170.cpp new file mode 100644 index 0000000..fd0e261 --- /dev/null +++ b/src/sejinpark/Sweeping/2170.cpp @@ -0,0 +1,31 @@ +#include "bits/stdc++.h" +using namespace std; +int n; +int main(void) { + ios::sync_with_stdio(0); + cin.tie(0); + cin >> n; + vector> V; + for (int i = 0; i < n; i++) { + int x, y; + cin >> x >> y; + V.push_back({x, y}); + } + sort(V.begin(), V.end()); + int start = V[0].first; + int end = V[0].second; + int len = 0; + for (int i = 1; i < n; i++) { + int from = V[i].first; + int to = V[i].second; + if (from <= end) { + end = (to > end ? to : end); + } else { + len += end - start; + start = from; + end = to; + } + } + len += end - start; + cout << len; +} \ No newline at end of file From a8f7c0528c8b6184d6b9e399b7e415357f2cd4cb Mon Sep 17 00:00:00 2001 From: RealWorldd Date: Mon, 6 Feb 2023 12:42:24 +0900 Subject: [PATCH 2/4] =?UTF-8?q?2836/=20=EA=B3=A8=EB=93=9C3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sejinpark/Sweeping/2836.cpp | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/sejinpark/Sweeping/2836.cpp diff --git a/src/sejinpark/Sweeping/2836.cpp b/src/sejinpark/Sweeping/2836.cpp new file mode 100644 index 0000000..8e24a8f --- /dev/null +++ b/src/sejinpark/Sweeping/2836.cpp @@ -0,0 +1,37 @@ +#include "bits/stdc++.h" +using namespace std; +using ll = long long; +int n, m; +int main(void){ + ios::sync_with_stdio(0); + cin.tie(0); + cin >> n >> m; + vector> V; + for (int i = 0; i < n; i++) { + ll a, b; + cin >> a >> b; + if(a > b) { + V.push_back({b,a}); + continue; + } + } + sort(V.begin(), V.end()); + ll start = V[0].first; + ll end = V[0].second; + ll len = 0; + ll ans = m; + for (int i = 1; i < V.size(); i++) { + auto from = V[i].first; + auto to = V[i].second; + if(from <= end) { + end = (to > end ? to : end); + } else { + len += end - start; + start = from; + end = to; + } + } + len += end - start; + ans += 2 * len; + cout << ans; +} From 44a50d5f26eee0dd348a719ce1a2f0b8a0f82e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=84=B8=EC=A7=84?= Date: Mon, 20 Feb 2023 15:54:06 +0900 Subject: [PATCH 3/4] =?UTF-8?q?10815/=20=EC=8B=A4=EB=B2=845?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sejinpark/Binary_Search/10815.cpp | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/sejinpark/Binary_Search/10815.cpp diff --git a/src/sejinpark/Binary_Search/10815.cpp b/src/sejinpark/Binary_Search/10815.cpp new file mode 100644 index 0000000..fb59f70 --- /dev/null +++ b/src/sejinpark/Binary_Search/10815.cpp @@ -0,0 +1,32 @@ +#include "bits/stdc++.h" +using namespace std; +int n, m; +int cards[500001]; +int hCards[500001]; +int main(void){ + ios::sync_with_stdio(0); + cin.tie(0); + cin >> n; + for (int i = 0; i < n; i++) { + int num; + cin >> num; + cards[i] = num; + } + cin >> m; + for (int i = 0; i < m; i++) { + int num; + cin >> num; + hCards[i] = num; + } + sort(cards, cards + n); + for (int i = 0; i < m; i++) { + if (binary_search(cards, cards + n, hCards[i])) { + hCards[i] = 1; + continue; + } + hCards[i] = 0; + } + for (int i = 0; i < m; i++) { + cout << hCards[i] << " "; + } +} \ No newline at end of file From d267c33ff123be4038ea64fe3e7c095e4050b1f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=84=B8=EC=A7=84?= Date: Mon, 20 Feb 2023 18:09:37 +0900 Subject: [PATCH 4/4] =?UTF-8?q?1822/=20=EC=8B=A4=EB=B2=844?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sejinpark/Binary_Search/1822.cpp | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/sejinpark/Binary_Search/1822.cpp diff --git a/src/sejinpark/Binary_Search/1822.cpp b/src/sejinpark/Binary_Search/1822.cpp new file mode 100644 index 0000000..14c620b --- /dev/null +++ b/src/sejinpark/Binary_Search/1822.cpp @@ -0,0 +1,36 @@ +#include "bits/stdc++.h" +using namespace std; +int a, b; +int arrA[500001]; +int arrB[500001]; +int main(void){ + ios::sync_with_stdio(0); + cin.tie(0); + cin >> a >> b; + for (int i = 0; i < a; i++) { + int num; + cin >> num; + arrA[i] = num; + } + for (int i = 0; i < b; i++) { + int num; + cin >> num; + arrB[i] = num; + } + sort(arrB, arrB + b); + vector V; + for (int i = 0; i < a; i++) { + if (!binary_search(arrB, arrB + b, arrA[i])) { + V.push_back(arrA[i]); + } + } + if (V.empty()) { + cout << 0; + return 0; + } + sort(V.begin(), V.end()); + cout << V.size() << "\n"; + for (auto i: V) { + cout << i << " "; + } +} \ No newline at end of file