Pagini recente » Cod sursa (job #996714) | Clasament pregatire_oji_11-12 | Cod sursa (job #2704469) | Cod sursa (job #2972885) | Cod sursa (job #287846)
Cod sursa(job #287846)
#include<stdio.h>
#include<limits.h>
#define NM 6000001
int main()
{
freopen("ssm.in","r",stdin);
freopen("ssm.out","w",stdout);
int n,i,v[NM],smax=INT_MIN,sc,st,dr;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&v[i]);
sc=0;
for(i=1;i<=n;i++)
{
if(sc<0){sc=v[i];st=i;}
else {sc=sc+v[i];}
if(sc>smax){smax=sc;dr=i;}
}
printf("%d %d %d",smax,st,dr);
return 0;
}