Skip to content
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

[소병희] - 동전, 호텔, 멀쩡한 사각형, 택배 배송 #247

Merged
merged 1 commit into from
Apr 21, 2024

Conversation

bngsh
Copy link
Contributor

@bngsh bngsh commented Apr 21, 2024

📌 from issue #244 📌

📋문제 목록📋

동전, 택배 배송: ✅
호텔, 멀쩡한 사각형: ⛔️

@bngsh bngsh added the 병희 label Apr 21, 2024
@bngsh bngsh self-assigned this Apr 21, 2024
Comment on lines +25 to +30
for(i in 1 .. c * 100) {
if (dp[i] >= c) {
println(i)
return@with
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그냥 print(dp[c])하면 안되나요?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

인덱스가 인원수가 아니라 가격이라서 이렇게 해줘야 했어요 흑흑

pq.add(Node(0, 0))
while(pq.isNotEmpty()) {
val (i, v) = pq.poll()
if (dist[i] <= v) continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 이거 하면 좀 더 빠르겠네요!

Comment on lines +4 to +11
fun solution(w: Int, h: Int): Long {
val gcd = gcd(w, h)
val sw = w / gcd
val sh = h / gcd
val adj = 1 + (sw - 1) + (sh - 1)

return (0L + w) * h - gcd * adj
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"가로지는 선" 풀이 잘 들었습니다!😀

Comment on lines +5 to +7
class 소병희_택배배송 {
companion object {
data class Node(val i: Int, val v: Int)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

틀렸던 부분 말씀 주셔서 좋았어요!
참고해서 풀어보겠습니다🫡

Comment on lines +17 to +24
for(p in 1 .. price) {
for((i, c) in coins.withIndex()) {
if (p < c) continue
for(pre in 0 .. i) {
dp[p][i] += dp[p - c][pre]
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

설명 주셔서 감사했습니다! 출력하면서 다시금 파악해야겠어요!🫡

@bngsh bngsh merged commit 7f521a5 into main Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants