Pagini recente » Cod sursa (job #942475) | Cod sursa (job #592775) | Cod sursa (job #639803) | Cod sursa (job #1847798) | Cod sursa (job #1571601)
#include <cstdio>
using namespace std;
int a[6000005],best[6000005],i,smax,in,sf,n,inmax;
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;
inmax=in;
}
}
printf("%d %d %d",smax,inmax,sf);
return 0;
}