Skip to content

Commit

Permalink
Merge pull request #2 from AlgoLeadMe/1-kangrae-jo
Browse files Browse the repository at this point in the history
1-kangrae-jo
  • Loading branch information
kangrae-jo authored Oct 1, 2024
2 parents c81e492 + 4e8e95d commit 8a261a4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
Binary file modified kangrae-jo/.DS_Store
Binary file not shown.
30 changes: 30 additions & 0 deletions kangrae-jo/DP/1-kangrae-jo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int solution(vector<int>& s, int n) {
// maxendpoint
vector<int> 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<int> s(n+1,0);
for (int i = 1; i <= n; i++) cin >> s[i];

cout << solution(s, n);

return 0;
}
2 changes: 1 addition & 1 deletion kangrae-jo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|
---

0 comments on commit 8a261a4

Please sign in to comment.