From 8167f59445e24ba6eeb10c3a99a626d2e77110a3 Mon Sep 17 00:00:00 2001 From: SW <34030977+Kaifeel@users.noreply.github.com> Date: Fri, 21 Aug 2026 19:34:45 +0900 Subject: [PATCH] =?UTF-8?q?2026-08-21=20=EC=85=94=ED=8B=80=EB=B2=84?= =?UTF-8?q?=EC=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kaifeel/README.md | 3 + ...4\355\213\200\353\262\204\354\212\244.cpp" | 63 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 "Kaifeel/\352\265\254\355\230\204/\354\205\224\355\213\200\353\262\204\354\212\244.cpp" diff --git a/Kaifeel/README.md b/Kaifeel/README.md index d1ab9d6..f9fdf5c 100644 --- a/Kaifeel/README.md +++ b/Kaifeel/README.md @@ -7,3 +7,6 @@ | 5차시 | 2026.07.01 | 최소 편집 | #32| | 6차시 | 2026.07.07 | 트로미노 | #35| | 7차시 | 2026.07.13 | 다리만들기 2 | #36| +| 8차시 | 2026.08.10| Maximal Rectangle | #37| +| 9차시 | 2026.08.16| Cookies and Greedy Takahashi | #39| +| 10차시 | 2026.08.21| 셔틀버스 | #41| diff --git "a/Kaifeel/\352\265\254\355\230\204/\354\205\224\355\213\200\353\262\204\354\212\244.cpp" "b/Kaifeel/\352\265\254\355\230\204/\354\205\224\355\213\200\353\262\204\354\212\244.cpp" new file mode 100644 index 0000000..5b761e6 --- /dev/null +++ "b/Kaifeel/\352\265\254\355\230\204/\354\205\224\355\213\200\353\262\204\354\212\244.cpp" @@ -0,0 +1,63 @@ +#include +#include +#include +#include + +using namespace std; + +string solution(int n, int t, int m, vector timetable) +{ + string answer = ""; + sort(timetable.begin(), timetable.end()); + + deque times; + + for (auto &time : timetable) + { + int t = stoi(time.substr(0, 2)) * 60 + stoi(time.substr(3, 2)); + times.push_back(t); + } + + int shuttle = 9 * 60; + int ptime = 0; + + for (int bus = 0; bus < n; ++bus) + { + + int member_cnt = 0; + int lastTime = 0; + + while (!times.empty() && times.front() <= shuttle && member_cnt < m) + { + lastTime = times.front(); + times.pop_front(); + + member_cnt++; + } + + if (bus == n - 1) + { + if (member_cnt == m) + { + ptime = lastTime - 1; + } + else + { + ptime = shuttle; + } + } + + shuttle += t; + } + + string hour = to_string(ptime / 60); + string minute = to_string(ptime % 60); + + if (hour.size() == 1) + hour = "0" + hour; + + if (minute.size() == 1) + minute = "0" + minute; + + return hour + ":" + minute; +} \ No newline at end of file