Pagini recente » Cod sursa (job #444225) | Cod sursa (job #1226444) | Cod sursa (job #219213) | Cod sursa (job #2772249) | Cod sursa (job #1206580)
#include<cstdio>
int main()
{
freopen("ssm.in","r",stdin);
freopen("ssm.out","w",stdout);
int s,smax,nr,i,n,ii,inf,ics,minn=-2000000000;
s=0;
smax=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&nr);
s+=nr;
if(s<0)
{
s=0;
ii=i+1;
inf=i+1;
}
if(s>=smax)
{
inf=i;
smax=s;
}
if(nr>minn)
{
minn=nr;
ics=i;
}
}
if(s!=0)
printf("%d %d %d",smax,ii,inf);
else
{
printf("%d %d %d",minn,ics,ics);
}
return 0;
}