From 662accddf7e825fa82e10edd7881e2c623b45989 Mon Sep 17 00:00:00 2001 From: sep037 Date: Sat, 24 May 2025 10:09:34 +0900 Subject: [PATCH 1/2] =?UTF-8?q?2025-05-24=20=ED=87=B4=EC=82=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #29 --- sep037/BruteForce/BOJ_14501.swift | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 sep037/BruteForce/BOJ_14501.swift 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) From d9615f62d5d7a7a234d53b9d13e89c2e74977484 Mon Sep 17 00:00:00 2001 From: SeungEun <112964257+sep037@users.noreply.github.com> Date: Sat, 24 May 2025 10:35:34 +0900 Subject: [PATCH 2/2] Update README.md --- sep037/README.md | 1 + 1 file changed, 1 insertion(+) 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| ---