#include<bits/stdc++.h>
#define ll long int
using namespace std;
int main()
{
ll n, m, i;
vector<ll>v;
while(cin >> m && m != 0)
{
ll finals = 0, total = 0;
for(i=1; i<=m; i++)
{
cin >> n;
total = total + n;
if(finals < total)
{
finals = total;
v.push_back(n);
}
}
if(v.size() == 0)
{
cout << 0 << endl;
v.clear();
continue;
}
for(i=0; i<v.size(); i++)
{
cout << v[i];
if(i != v.size()-1)
cout << " ";
}
cout << endl;
v.clear();
}
return 0;
}
#define ll long int
using namespace std;
int main()
{
ll n, m, i;
vector<ll>v;
while(cin >> m && m != 0)
{
ll finals = 0, total = 0;
for(i=1; i<=m; i++)
{
cin >> n;
total = total + n;
if(finals < total)
{
finals = total;
v.push_back(n);
}
}
if(v.size() == 0)
{
cout << 0 << endl;
v.clear();
continue;
}
for(i=0; i<v.size(); i++)
{
cout << v[i];
if(i != v.size()-1)
cout << " ";
}
cout << endl;
v.clear();
}
return 0;
}
Comments
Post a Comment