728x90
๋ฐ์ํ
Problem
Solution
1.timetable์ ์ ์ ์๊ฐ ์์ผ๋ก ์ ๋ ฌํ๋ค.
var times:[Int] = timetable.map{Int($0.split(separator: ":")[0])!*60 + Int($0.split(separator: ":")[1])!}.sorted(by:<)
2. ๊ฐ ์๊ฐ๋ง๋ค ํ ์ ์๋ ์ฌ๋๋ค์ timetable์์ ์ญ์ ํด์ค๋ค.
for _ in 0..<n {
people = m
for _ in 0..<m {
if times.isEmpty || times.first! > time { break }
last = times.removeFirst()
people -= 1
}
time += t
}
3. ๊ฐ์ฅ ๋ง์ง๋ง ๋ฒ์ค์ ํ ์ ์๋์ง ํ์ธํ๋ค.
๋ง์ฝ ๊ฐ์ฅ ๋ง์ง๋ง ๋ฒ์ค์ ํ ์๋ฆฌ๊ฐ ๋จ์๋ค๋ฉด ๋ง์ง๋ง ๋ฒ์ค๊ฐ ์จ ์๊ฐ์ ๋ฐํํ๊ณ
์๋ฆฌ๊ฐ ์๋ค๋ฉด ๊ฐ์ฅ ๋ง์ง๋ง์ ํ ์ฌ๋๋ณด๋ค 1๋ถ ๋น ๋ฅธ ์๊ฐ์ ๋ฐํํ๋ฉด ๋๋ค.
time = people == 0 ? last-1 : time-t
hour = time/60 < 10 ? "0\(time/60)" : "\(time/60)"
minute = time%60 < 10 ? "0\(time%60)" : "\(time%60)"
return hour + ":" + minute
Source Code
728x90
๋ฐ์ํ
'๐ Problem Solution > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Swift] 2021 KAKAO INTERNSHIP ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ (0) | 2021.08.07 |
---|---|
[Swift] ํ๋ก๊ทธ๋๋จธ์ค ์ํด๋ฆฌ ์ฑ๋ฆฐ์ง 1์ฃผ์ฐจ ๋ถ์กฑํ ๊ธ์ก ๊ณ์ฐํ๊ธฐ (0) | 2021.08.07 |
[Swift] 2020 KAKAO INTERNSHIP ๋ณด์ ์ผํ (0) | 2021.08.04 |
[Swift] 2020 KAKAO BLIND RECRUITMENT ๋ธ๋ก ์ด๋ํ๊ธฐ (0) | 2021.08.03 |
[Swift] 2019 KAKAO WINTER INTERNSHIP ์ง๊ฒ๋ค๋ฆฌ ๊ฑด๋๊ธฐ (0) | 2021.07.23 |
๋๊ธ