Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MuchanKim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
| 2์ฐจ์‹œ | 2025.04.11 | ์—๋ผํ† ์Šคํ…Œ๋„ค์Šค์˜์ฑ„ | [์†Œ-๋‚œ๋‹ค!](https://www.acmicpc.net/problem/19699)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/10|
| 3์ฐจ์‹œ | 2025.04.29 | ๊ทธ๋ฆฌ๋”” | [์•Œ๋ฐ”์ƒ ๊ฐ•ํ˜ธ](https://www.acmicpc.net/problem/1758)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/14|
| 4์ฐจ์‹œ | 2025.05.11 | ๊ตฌํ˜„ | [์˜คํ”ˆ์ฑ„ํŒ…๋ฐฉ](https://school.programmers.co.kr/learn/courses/30/lessons/42888)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/20|
| 5์ฐจ์‹œ | 2025.05.22 | ์ด๋ถ„ํƒ์ƒ‰ | [ํฉ๋‚ ๋ฆฌ๋Š” ์‹œํ—˜์ง€ ์†์—์„œ ๋‚ด ํ‰์ ์ด ๋А๊ปด์ง„๊ฑฐ์•ผ](https://www.acmicpc.net/problem/17951)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/25|

---
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import Foundation
Copy link
Member

Choose a reason for hiding this comment

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

์™€. ใ…‹ใ…‹ ๋ฌธ์ œ ์กฐ๊ฑด์—์„œ ๊ทธ๋ƒฅ K๊ฐœ ๊ทธ๋ฃน์œผ๋กœ ๋‚˜๋ˆˆ๋‹ค~๋Š” ๊ฑธ

"๊ท ๋“ฑํ•œ ๊ฐœ์ˆ˜์˜ ์‹œํ—˜์ง€๋ฅผ ๊ฐ–๋Š” K๊ฐœ ๊ทธ๋ฃน"์œผ๋กœ ๋‚˜๋ˆˆ๋‹ค๊ณ  ์ฐฉ๊ฐํ•ด์„œ
๋ฉ์ฒญ์‹œ๊ฐ„ 1์‹œ๊ฐ„ 30๋ถ„ ๋ณด๋‚ด๊ณ  ์™œ ๋„๋Œ€์ฒด ์•ˆํ’€๋ฆฌ๋‚˜ ํ–ˆ๋„ค์š”.
์ฒ˜์Œ๋ถ€ํ„ฐ ๋‹ค์‹œ ์‹œ์ž‘ํ•˜๋Ÿฌ ๊ฐ‘๋‹ˆ๋‹ค..

Copy link
Member

Choose a reason for hiding this comment

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

์™ค์บ easyํ•œ๊ฐ€ ํ–ˆ๋„ค..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ใ…‹ใ…‹ใ…‹ ์ €๋„ ๊ทธ๋ ‡๊ฒŒ ์ƒ๊ฐํ–ˆ์–ด์š”... PR์— ์„ค๋ช…ํ•œ๋‹ค๊ณ  ์ ์—ˆ๋Š”๋ฐ ๋ถ€์กฑํ–ˆ๋„ค์š”.. sry,,


// ๊ทธ๋ฃน ์ˆ˜ 1 ~ 10^5
let input = readLine()!.split(separator: " ").map { Int($0)! }
let group = input[1]

let scores = readLine()!.split(separator: " ").map { Int($0)! }

func canMakeGroups(_ scores: [Int], _ target: Int, _ group: Int) -> Bool {
var sum = 0
var count = 0

for score in scores {
sum += score
if sum >= target {
count += 1
sum = 0
}
}
Comment on lines +9 to +19
Copy link
Collaborator

Choose a reason for hiding this comment

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

๋กœ์ง ๋ถ„๋ฆฌํ•œ๊ฑฐ ๋ณด๊ธฐ ์ข‹์•„์š” ๐Ÿ‘


return count >= group
}

func solution(_ scores: [Int], _ group: Int) -> Int {
var start = 0
var end = scores.reduce(0, +)
var res = 0

while start <= end {
let mid = (start + end) / 2

if canMakeGroups(scores, mid, group) {
res = mid
start = mid + 1
} else {
end = mid - 1
}
}

return res
}

print(solution(scores, group))