-
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
[소병희] 표현 가능한 이진트리, 절댓값 힙, 치즈, 치킨 배달 #112
Conversation
companion object { | ||
fun solve(): Unit = with(BufferedReader(InputStreamReader(System.`in`))) { | ||
val n = readLine().toInt() | ||
val pq = PriorityQueue<Int> { a, b -> if (a + b == 0) a - b else abs(a) - abs(b) } |
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.
pq를 굉장히 아름답게 쓰시네요,, 항상 배우고 갑니당
fun checkSubTree(s: Int, e: Int, parent: Int) : Int { | ||
val mid = (s + e) / 2 | ||
val root = sb[mid] - '0' | ||
if (root == 1 && parent == 0) return 0 | ||
if (s == e) return 1 | ||
|
||
if (checkSubTree(s, mid - 1, root) == 0) return 0 | ||
return checkSubTree(mid + 1, e, root) | ||
} |
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.
재귀 장인이시군요
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.
인졍..!
fun checkSubTree(s: Int, e: Int, parent: Int) : Int { | ||
val mid = (s + e) / 2 | ||
val root = sb[mid] - '0' | ||
if (root == 1 && parent == 0) return 0 | ||
if (s == e) return 1 | ||
|
||
if (checkSubTree(s, mid - 1, root) == 0) return 0 | ||
return checkSubTree(mid + 1, e, root) | ||
} |
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.
인졍..!
|
||
val houseCnt = house.size | ||
val franchiseCnt = franchise.size | ||
val distMap = Array(houseCnt) { h -> IntArray(franchiseCnt) { f -> house[h].calcDist(franchise[f]) } } |
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.
거리를 미리 저장하시다니!👍
val m = input() | ||
val house = mutableListOf<Pair<Int, Int>>() | ||
val franchise = mutableListOf<Pair<Int, Int>>() | ||
var cityDist = Integer.MAX_VALUE |
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.
Int의 상수 대신 Interger의 상수를 사용하신 이유가 있으신가요??
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.
ㅇㅁㅇ 아뇨 자바랑 헷갈렸나봐요 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ
} | ||
|
||
fun makeM(f: Int, i: Int, chickenDist: IntArray) { | ||
if (f == franchiseCnt && i < m) return |
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.
조건처리가 좋은 것 같습니다..!!!
|
||
for(i in numbers.indices) { | ||
sb.clear() | ||
sb.append(java.lang.Long.toBinaryString(numbers[i])) |
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.
Long도 toBinaryString이 있군요...
📌 from issue #111 📌
📋문제 목록📋