#include <iostream>#include <algorithm>#include <vector>using namespace std;int fastestMaxSum(const vector<int> & v){int sum = 0, psum = 0, i;for (i = 0; i < v.size(); i++){psum = max(psum, 0) + v[i];sum = max(psum, sum);}return sum;}int main(){int n, i;cin >> n;vector<int> v(n);for (i = 0; i < n; i++){int num;cin >> num;v.push_back(num);}cout << fastestMaxSum(v);}
'백준' 카테고리의 다른 글
[9252] LCS 2 (0) | 2018.10.20 |
---|---|
[9251] LCS (0) | 2018.10.20 |
[1547] 공 (0) | 2018.10.20 |
[1065] 한수 (0) | 2018.10.20 |
[7568] 덩치 (0) | 2018.10.20 |