From cde53ab6d0e46438bd38719b31eea4fd316d5889 Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Sun, 18 Jan 2026 16:29:04 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[Week02]=20BOJ:=20=ED=87=B4=EC=82=AC2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../whqtker.cpp" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "weekly/week02/BOJ_15486_\355\207\264\354\202\2542/whqtker.cpp" diff --git "a/weekly/week02/BOJ_15486_\355\207\264\354\202\2542/whqtker.cpp" "b/weekly/week02/BOJ_15486_\355\207\264\354\202\2542/whqtker.cpp" new file mode 100644 index 0000000..a645da3 --- /dev/null +++ "b/weekly/week02/BOJ_15486_\355\207\264\354\202\2542/whqtker.cpp" @@ -0,0 +1,27 @@ +#include +#include + +using namespace std; + +int dp[1500051]; +pair consult[1500001]; // consult[i] = { x, y } : i일의 상담은 x일이 걸리며 수익은 y + +int main() { + int n; + cin >> n; + for (int i = 1; i <= n; i++) { + int x, y; + cin >> x >> y; + consult[i] = { x, y }; + } + + for (int i = 1; i <= n; i++) { + dp[i + 1] = max(dp[i + 1], dp[i]); + + if (i + consult[i].first <= n + 1) { + dp[i + consult[i].first] = max(dp[i + consult[i].first], dp[i] + consult[i].second); + } + } + + cout << dp[n + 1] << "\n"; +} \ No newline at end of file From 6c7e7cbcb6217296dfe5005d9f569aecec19ef72 Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Sat, 24 Jan 2026 14:42:07 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[Week03]=20BOJ:=20=ED=9C=B4=EA=B2=8C?= =?UTF-8?q?=EC=86=8C=20=EC=84=B8=EC=9A=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../whqtker.cpp" | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 "weekly/week3/BOJ_1477_\355\234\264\352\262\214\354\206\214 \354\204\270\354\232\260\352\270\260/whqtker.cpp" diff --git "a/weekly/week3/BOJ_1477_\355\234\264\352\262\214\354\206\214 \354\204\270\354\232\260\352\270\260/whqtker.cpp" "b/weekly/week3/BOJ_1477_\355\234\264\352\262\214\354\206\214 \354\204\270\354\232\260\352\270\260/whqtker.cpp" new file mode 100644 index 0000000..9c7c299 --- /dev/null +++ "b/weekly/week3/BOJ_1477_\355\234\264\352\262\214\354\206\214 \354\204\270\354\232\260\352\270\260/whqtker.cpp" @@ -0,0 +1,57 @@ +#include +#include +#include + +using namespace std; + +vector v; + +// 휴게소 간 최대 거리를 x로 했을 때, 설치 가능한 휴게소의 수를 리턴 +int chk(int x) { + int cnt = 0; + for (int i = 0; i < v.size() - 1; i++) { + int gap = v[i + 1] - v[i]; + + if (gap % x == 0) { + cnt += gap / x - 1; + } + else { + cnt += gap / x; + } + } + + return cnt; +} + +int main() { + int n, m, l; + cin >> n >> m >> l; + + for (int i = 0; i < n; i++) { + int x; + cin >> x; + v.push_back(x); + } + v.push_back(0); + v.push_back(l); + + sort(v.begin(), v.end()); + + int left = 1; + int right = l; + int mid; + while (left <= right) { + mid = (left + right) / 2; // mid: 휴게소 간 최대 거리 + + int cnt = chk(mid); + + if (cnt <= m) { + right = mid - 1; + } + else { + left = mid + 1; + } + } + + cout << left; +} \ No newline at end of file