-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from AlgoLeadMe/8-jung0115
8-jung0115
- Loading branch information
Showing
3 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// 8차시 2024.08.19.월 : 프로그래머스 - 입국심사(Lv.3) | ||
class Solution { | ||
fun solution(n: Int, times: IntArray): Long { | ||
var min: Long = 0 | ||
var max: Long = (times.maxOrNull()!!.toLong() * n) | ||
|
||
while (min < max) { | ||
val mid: Long = (min + max) / 2 | ||
var complete: Long = 0 | ||
|
||
for (time in times) { | ||
complete += mid / time | ||
} | ||
|
||
if (complete >= n) { | ||
max = mid | ||
} else { | ||
min = mid + 1 | ||
} | ||
} | ||
|
||
return min | ||
} | ||
} |