Pagini recente » Cod sursa (job #834587) | Cod sursa (job #3133128) | Cod sursa (job #1656753) | Cod sursa (job #3225668) | Cod sursa (job #1571580)
#include <cstdio>
using namespace std;
int a[6000005],best[6000005],i,smax,in,sf,n;
int main()
{
freopen("ssm.in","r",stdin);
freopen("ssm.out","w",stdout);
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(i=1;i<=n;i++)
{
best[i]=a[i];
if(best[i]<best[i-1]+a[i])
best[i]=best[i-1]+a[i];
else
if(i-1!=0)
{if(best[i]>best[i-1]+a[i])
in=i;}
else
if(best[i]==best[i-1]+a[i])
in=i;
if(best[i]>smax)
{
smax=best[i];
sf=i;
}
}
printf("%d %d %d",smax,in,sf);
return 0;
}