8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 76f2af3 commit 955d3a3Copy full SHA for 955d3a3
0x10/solutions/1912.cpp
@@ -1,11 +1,12 @@
1
// Authored by : Hot6Mania
2
-// Co-authored by : -
3
-// http://boj.kr/a9a359faddb34f0faf591d3421b0e6af
+// Co-authored by : BaaaaaaaaaaarkingDog
+// http://boj.kr/1fb4beecefac47d7a7f45f97f3189806
4
#include <bits/stdc++.h>
5
using namespace std;
6
7
int n;
8
-int a[100010], d[100010];
+int a[100010];
9
+int d[100010]; // d[i] : i번째 항으로 끝나는 연속합 중 최대
10
11
int main(void){
12
ios::sync_with_stdio(0);
@@ -14,9 +15,8 @@ int main(void){
14
15
cin >> n;
16
for(int i = 1; i <= n; ++i){
17
cin >> a[i];
- d[i] = a[i];
18
}
19
for(int i = 1; i <= n; ++i)
20
- d[i] = max(d[i], d[i-1] + a[i]);
+ d[i] = max(0, d[i-1]) + a[i];
21
cout << *max_element(d + 1, d + n + 1);
22
0 commit comments