diff --git a/kangrae-jo/.DS_Store b/kangrae-jo/.DS_Store index 5008ddf..cffb731 100644 Binary files a/kangrae-jo/.DS_Store and b/kangrae-jo/.DS_Store differ diff --git a/kangrae-jo/DP/1-kangrae-jo.cpp b/kangrae-jo/DP/1-kangrae-jo.cpp new file mode 100644 index 0000000..3d9a8d7 --- /dev/null +++ b/kangrae-jo/DP/1-kangrae-jo.cpp @@ -0,0 +1,30 @@ +#include +#include +#include + +using namespace std; + +int solution(vector& s, int n) { + // maxendpoint + vector dp(n + 1, 0); + dp[1] = s[1]; + + int maxSum = dp[1]; + for (int i = 2; i <= n; i++) { + dp[i] = max(dp[i - 1] + s[i], s[i]); + if (dp[i] > maxSum) maxSum = dp[i]; + } + + return maxSum; +} + +int main() { + int n; + cin >> n; + vector s(n+1,0); + for (int i = 1; i <= n; i++) cin >> s[i]; + + cout << solution(s, n); + + return 0; +} \ No newline at end of file diff --git a/kangrae-jo/README.md b/kangrae-jo/README.md index 9b095df..16c0ace 100644 --- a/kangrae-jo/README.md +++ b/kangrae-jo/README.md @@ -2,5 +2,5 @@ | 차시 | 날짜 | 문제유형 | 링크 | 풀이 | |:----:|:---------:|:----:|:-----:|:----:| -| 1차시 | 2024.10.01 | 구현 | [추억 점수](https://school.programmers.co.kr/learn/courses/30/lessons/176963)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/35| +| 1차시 | 2024.09.28 | DP | [연속합](https://www.acmicpc.net/problem/1912)|[#2]https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/2| ---