題目敘述:https://zerojudge.tw/ShowProblem?problemid=b565
#include <iostream>
using namespace std;
int main(){
int n, temp, total, maxi;
while (cin >> n){
maxi = 0;
total = 0;
for (int i = 0; i < n; i++){
cin >> temp;
total += temp;
maxi = max(maxi, total);
if (total < 0) total = 0;
}
cout << maxi << "\n";
}
}