Skip to content

Instantly share code, notes, and snippets.

@moo1o
Created April 14, 2017 09:50
Show Gist options
  • Save moo1o/f6bd2a3298e657172c8e8eca7e92bfe6 to your computer and use it in GitHub Desktop.
Save moo1o/f6bd2a3298e657172c8e8eca7e92bfe6 to your computer and use it in GitHub Desktop.
//
// 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