Pagini recente » Cod sursa (job #237080) | Cod sursa (job #2968465) | Cod sursa (job #1597011) | Cod sursa (job #288332) | Cod sursa (job #305075)
Cod sursa(job #305075)
#include<stdio.h>
long long n,x,i,s,maxx=-12000000,poz,smax=-12000000,is,im,sfm;
int main()
{
freopen("ssm.in","r",stdin);
freopen("ssm.out","w",stdout);
scanf("%lld%lld",&n,&x);
s=smax=x;
is=im=sfm=1;
for(i=2;i<=n;++i)
{
scanf("%lld",&x);
if(x>maxx)
{
maxx=x;
poz=i;
}
if(s+x>x)
s+=x;
else
{
s=x;
is=i;
}
if(s>smax)
{
smax=s;
im=is;
sfm=i;
}
}
if(smax>=maxx)
printf("%lld %lld %lld\n",smax,im,sfm);
else
printf("%lld %lld %lld\n",maxx,poz,poz);
return 0;
}