From 9f48110e0de74b0c0b96dabd85e539a611b70249 Mon Sep 17 00:00:00 2001 From: sh0723 Date: Mon, 14 Sep 2026 14:27:02 +0900 Subject: [PATCH 1/2] =?UTF-8?q?14003=20:=20=EA=B0=80=EC=9E=A5=20=EA=B8=B4?= =?UTF-8?q?=20=EC=A6=9D=EA=B0=80=ED=95=98=EB=8A=94=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EC=88=98=EC=97=B4=205=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week6/BOJ14003/BOJ14003_V1.cpp | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/week6/BOJ14003/BOJ14003_V1.cpp diff --git a/src/week6/BOJ14003/BOJ14003_V1.cpp b/src/week6/BOJ14003/BOJ14003_V1.cpp new file mode 100644 index 0000000..5dd21d1 --- /dev/null +++ b/src/week6/BOJ14003/BOJ14003_V1.cpp @@ -0,0 +1,45 @@ +#include +using namespace std; +int N; +int lis[1000000]; +pair res[1000000]; +stack stk; +int main() { + + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); + + fill(lis, lis + 1000000, INT_MAX); + int len = 0; + cin >> N; + for (int i=0; i> num; + auto lower_pos = lower_bound(lis, lis + len, num); // 위치 + int _pos = (int)(lower_bound(lis, lis + len, num) - lis); // index 번호 + + if (*lower_pos == INT_MAX) len++; + *lower_pos = num; + + res[i].first = _pos; + res[i].second = num; + } + + cout << len << '\n'; + for (int i=N-1; i>=0; i--) { + if (res[i].first == len-1) { + stk.push(res[i].second); + len--; + } + } + + while(!stk.empty()) { + cout << stk.top() << " "; + + stk.pop(); + } + + + return 0; +} \ No newline at end of file From 2c068fc31e3dab2e8852f640918e2469333c48d4 Mon Sep 17 00:00:00 2001 From: sh0723 Date: Mon, 14 Sep 2026 14:28:34 +0900 Subject: [PATCH 2/2] =?UTF-8?q?14003=20:=20=EA=B0=80=EC=9E=A5=20=EA=B8=B4?= =?UTF-8?q?=20=EC=A6=9D=EA=B0=80=ED=95=98=EB=8A=94=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EC=88=98=EC=97=B4=205=20=EC=B6=9C=EB=A0=A5=20=EC=A0=95?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week6/BOJ14003/BOJ14003_V1.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/week6/BOJ14003/BOJ14003_V1.cpp b/src/week6/BOJ14003/BOJ14003_V1.cpp index 5dd21d1..b2f5ee8 100644 --- a/src/week6/BOJ14003/BOJ14003_V1.cpp +++ b/src/week6/BOJ14003/BOJ14003_V1.cpp @@ -34,12 +34,15 @@ int main() { } } + bool first = true; while(!stk.empty()) { - cout << stk.top() << " "; - + if (!first) cout << ' '; + cout << stk.top(); + first = false; stk.pop(); } + cout << '\n'; return 0; -} \ No newline at end of file +}