-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[소병희] 공유기 설치, 트리의 지름, 뮤탈리스크 #250
Conversation
if (cur > depth[i][0]) { | ||
depth[i][1] = depth[i][0] | ||
depth[i][0] = cur | ||
} | ||
else if (cur > depth[i][1]) { | ||
depth[i][1] = cur | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depth 에 2개까지의 max 값을 가져서 결과를 구하는 게 매우 좋았습니다! 👍👍
fun solve() = with(System.`in`.bufferedReader()) { | ||
val n = readLine().toInt() | ||
val tree = Array(n+1) { ArrayDeque<Node>() } | ||
val depth = Array(n+1) { IntArray(2) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depth에 저장하고 푸는 방식이 이해가 잘되어서 좋았습니다!
while(lm < rm - 1) { | ||
mid = (lm + rm) / 2 | ||
curC = getWifiCnt(mid) | ||
|
||
if (curC >= c) { | ||
lm = mid | ||
} | ||
else { | ||
rm = mid | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lm과 rm에 그대로 mid를 넣어주는게 뭔가 신기합니다!!
var lm = 1 | ||
var rm = house[n-1] - house[0] + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
가능한 범위, 불가능한 범위로 설명을 해주셔서 이해가 쉬웠어요!👍
📌 from issue #248 📌
📋문제 목록📋