diff --git a/sep037/BruteForce/BOJ_14501.swift b/sep037/BruteForce/BOJ_14501.swift new file mode 100644 index 0000000..54b23a8 --- /dev/null +++ b/sep037/BruteForce/BOJ_14501.swift @@ -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)] = [] +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)) +} + +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) +} + +workTime(day: 0, profit: 0) +print(maxProfit) diff --git a/sep037/README.md b/sep037/README.md index 6ad5f2c..b31932e 100644 --- a/sep037/README.md +++ b/sep037/README.md @@ -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| ---