Pagini recente » Cod sursa (job #772914) | Cod sursa (job #3130876) | Cod sursa (job #293868) | Cod sursa (job #2714314) | Cod sursa (job #287844)
Cod sursa(job #287844)
#include <stdio.h>
#define NM 6000000
#include <limits.h>
int main()
{
int n,v[NM+1],i,st,end,sc=0,smax=INT_MIN;
freopen("ssm.in","r",stdin);
freopen("ssm.out","w",stdout);
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&v[i]);
st=i=1;
for(i=1;i<=n;i++)
{
if(sc<0) {sc=v[i];
st=i;}
else sc=sc+v[i];
if(smax<sc) {smax=sc;
end=i;}
}
printf("%d %d %d",smax,st,end);
return 0;
}