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