Skip to content

Commit cd332ae

Browse files
committed
2024-03-02 연속합
1 parent a5f698b commit cd332ae

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

rivkms/DP/1912.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <iostream>
2+
#include <vector>
3+
4+
using namespace std;
5+
6+
int max(int a, int b) {
7+
return a > b ? a : b;
8+
}
9+
int main() {
10+
int m = -2147483647;
11+
int n, tmp;
12+
13+
cin >> n;
14+
vector<int> dp(n);
15+
vector<int> a(n);
16+
for (int i = 0; i < n; i++) {
17+
cin >> a[i];
18+
}
19+
dp[0] = a[0];
20+
for (int i = 0; i < n; i++) {
21+
dp[i] = max(dp[i - 1] + a[i], a[i]);
22+
if (m < dp[i]) m = dp[i];
23+
}
24+
cout << m;
25+
return 0;
26+
}

rivkms/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
|:----:|:---------:|:----:|:-----:|:----:|
55
| 1차시 | 2024.02.12 | DP | [평범한 배낭](https://www.acmicpc.net/problem/12865) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/5) |
66
| 2차시 | 2024.02.15 | Recursion | [하노이 탑 이동 순서](https://www.acmicpc.net/problem/11729) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/8) |
7-
| 3차시 | 2024.02.18 | DP | [하노이 탑 이동 순서](https://www.acmicpc.net/problem/10844) | [#3](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/11) |
8-
| 4차시 | 2024.02.18 | Backtracking | [N-queen](https://www.acmicpc.net/problem/9663) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/13) |
7+
| 3차시 | 2024.02.18 | DP | [쉬운 계단 수](https://www.acmicpc.net/problem/10844) | [#3](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/11) |
98
| 4차시 | 2024.02.18 | Backtracking | [N-queen](https://www.acmicpc.net/problem/9663) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/13) |
109
| 5차시 | 2024.02.24 | Backtracking | [입대](https://www.acmicpc.net/problem/31413) | [#5](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/18) |
1110
| 6차시 | 2024.02.27 | BFS | [토마토](https://www.acmicpc.net/problem/7576) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/20) |
11+
| 7차시 | 2024.03.01 | DP | [연속합](https://www.acmicpc.net/problem/1912) | [#7](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/25) |
1212
---

0 commit comments

Comments
 (0)