Pagini recente » Cod sursa (job #3159658) | Cod sursa (job #2579414) | Cod sursa (job #1782806) | Cod sursa (job #2821937) | Cod sursa (job #1461021)
#include <cstdio>
using namespace std;
int x[6000001];
int main()
{
freopen("ssm.in","r",stdin);
freopen("ssm.out","w",stdout);
int n,i,sc,ic,smax,im,sfm;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&x[i]);
sc=smax=x[1];
ic=im=sfm=1;
for(i=2;i<=n;i++)
{
if(sc+x[i]<x[i])
{
sc=x[i];
ic=i;
}
else
sc=sc+x[i];
if(sc>smax)
{
smax=sc;
im=ic;
sfm=i;
}
}
printf("%d ",smax);
printf("%d %d\n",im,sfm);
return 0;
}