Pagini recente » Diferente pentru utilizator/mathboy intre reviziile 98 si 99 | Cod sursa (job #3140739) | Cod sursa (job #3346515) | Diferente pentru utilizator/mathboy intre reviziile 39 si 40 | Cod sursa (job #3351666)
#include <fstream>
using namespace std;
ifstream fin ("ssm.in");
ofstream fout ("ssm.out");
int main()
{
int n,x,start=1,end,smax=0,s=0,i;
fin >> n;
for (i=1;i<=n;i++)
{
fin >> x;
s+=x;
if (s<0)
{
s=0;
start=i+1;
}
else if (s>smax)
{
end=i;
smax=s;
}
}
fout << smax << ' ' << start << " " << end;
return 0;
}