-
-
Save moo1o/f6bd2a3298e657172c8e8eca7e92bfe6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 1912.cpp | |
// AlgorithmTest | |
// | |
// Created by 김무열 on 2017. 4. 14.. | |
// Copyright © 2017년 김무열. All rights reserved. | |
// | |
#include <iostream> | |
#include <algorithm> | |
#include <vector> | |
using namespace std; | |
int m = 0; | |
void calcMax(vector<int> &ary, int index){ | |
if(index == ary.size()) return; | |
int sum = 0; | |
for(int i = index ; i<ary.size(); i++){ | |
sum += ary[i]; | |
if(m < sum) | |
m = sum; | |
} | |
calcMax(ary, index+1); | |
} | |
int main(void){ | |
int n; | |
cin >> n; | |
vector<int> ary(n); | |
for(int i=0; i< n ; i++){ | |
cin >> ary[i]; | |
} | |
calcMax(ary, 0); | |
cout << m << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment