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
33 changes: 33 additions & 0 deletions sep037/BruteForce/BOJ_14501.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// main.swift
// 14501
//
// Created by Seungeun Park on 5/24/25.
//

import Foundation

let N = Int(readLine()!)!
var profitFromWork : [(Int, Int)] = []
Copy link
Member

Choose a reason for hiding this comment

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

λ³€μˆ˜λͺ… μ™„λ²½ν•©λ‹ˆλ‹€. ^^..

Copy link
Collaborator Author

@sep037 sep037 May 25, 2025

Choose a reason for hiding this comment

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

γ…‹γ…‹γ…‹γ…‹γ…‹γ…‹γ…‹γ…‹γ…‹γ…‹γ…‹γ…‹γ…‹ γ„±γ……ν•©λ‹ˆλ‹€ ! 더 λ©‹μ§„ λ³€μˆ˜λͺ… μ§“κ³  싢은데 μ €λ ‡κ²Œ 직관적인 게 더 νŽΈν•΄μš” 사싀 .

var maxProfit = 0

for _ in 0 ..< N {
let input = readLine()!.split(separator: " ").map { Int($0)! }
let (time, profit) = (input[0], input[1])
profitFromWork.append((time, profit))
Comment on lines +16 to +17
Copy link
Collaborator

Choose a reason for hiding this comment

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

μ΄λŸ°μ‹μœΌλ‘œ λ‹΄μœΌμ…¨κ΅°μš”! time, profit이 μ‹€μ œ μ½”λ“œμ—μ„œ μ“°μ΄μ§„μ•Šμ•„μ„œ

profitFromWork.append((input[0], input[1]))
저라면 κ°„κ²°ν•˜κ²Œ μ΄λ ‡κ²Œ ν–ˆμ„ λ“―! 그치만 λ§ˆμΉ΄λ‘œλ‹ˆ 방식이 더 μ•ˆμ „ν•œ 것 κ°™μ•„μš”. κΌΌκΌΌν•œ λ§ˆμΉ΄λ‘œλ‹ˆμ”¨.

}

func workTime(day: Int, profit: Int){
if day >= N {
maxProfit = max(maxProfit, profit)
return
}

if day + profitFromWork[day].0 <= N {
workTime(day: day + profitFromWork[day].0, profit: profit + profitFromWork[day].1)
}
workTime(day: day + 1, profit: profit)
}
Comment on lines +26 to +30
Copy link
Member

Choose a reason for hiding this comment

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

옹 μž¬κ·€ν•¨μˆ˜λ₯Ό μ΄μš©ν•΄μ„œ μ „μ—­ λ³€μˆ˜μ— maxλ₯Ό μ‚¬μš©ν•΄μ„œ κ΅¬ν˜„ν•˜μ…¨λ„€μš”!!

Copy link
Collaborator

@MuchanKim MuchanKim May 30, 2025

Choose a reason for hiding this comment

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

μž…λ ₯ κ°’ μ΅œλŒ€μΉ˜κ°€ 15λΌμ„œ μ™„νƒν•˜λ©΄ λ˜κ² λ‹€ 생각을 ν–ˆλŠ”λ° μž¬κ·€λ‘œ 잘 κ΅¬ν˜„ν•˜μ‹  λ“―!


workTime(day: 0, profit: 0)
print(maxProfit)
1 change: 1 addition & 0 deletions sep037/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
| 2μ°¨μ‹œ | 2025.04.10 | DFS | [트리의 λΆ€λͺ¨ μ°ΎκΈ°](https://www.acmicpc.net/problem/11725)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/12|
| 3μ°¨μ‹œ | 2025.04.28 | μ •λ ¬ | [접미사 λ°°μ—΄](https://www.acmicpc.net/problem/11656)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/13|
| 4μ°¨μ‹œ | 2025.05.11 | DP | [1, 2, 3 λ”ν•˜κΈ°](https://www.acmicpc.net/problem/9095)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/21|
| 5μ°¨μ‹œ | 2025.05.24 | BruteForce | [퇴사](https://www.acmicpc.net/problem/14501)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/29|
Copy link
Collaborator

Choose a reason for hiding this comment

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

dfs둜 ν’€μ—ˆλŠ”λ° μ™œ μ—¬κΈ° 브루트포슀둜 λ„£μ—ˆμ–΄μš” λ§ˆμΉ΄λ‘œλ‹ˆμ”¨ γ…‹γ…‹

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ν—‰ 이게 뭐야

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

κΈ°μ–΅ μ•ˆλ‚¨ ;;


---