Pagini recente » Cod sursa (job #1569200) | Profil RolandPetrean | Profil andreifirst | Cod sursa (job #786064) | Cod sursa (job #1571569)
#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
in=i;
if(best[i]>smax)
{
smax=best[i];
sf=i;
}
}
printf("%d %d %d",smax,in,sf);
return 0;
}