Cod sursa(job #283102)

Utilizator jupanubv92Popescu Marius jupanubv92 Data 18 martie 2009 18:45:03
Problema Subsecventa de suma maxima Scor 95
Compilator cpp Status done
Runda Arhiva educationala Marime 0.5 kb
#include<stdio.h>

long long i,n,j;

int main()
{
  freopen("ssm.in","r",stdin);
  freopen("ssm.out","w",stdout);
  scanf("%lld",&n);
  long long ant,prim,cur,max,pzi=1,pzj=1;
  scanf("%lld",&prim);
  ant=prim;cur=prim;
  max=prim;
  for(i=2;i<=n;i++)
   {scanf("%lld",&prim);
    cur=prim;
    if(cur+ant>cur)
     cur=cur+ant;
     else j=i;
    if(cur>max)
     {max=cur;
      pzi=i;
      pzj=j;
     }
    ant=cur;
    }
  printf("%lld %lld %lld\n",max,pzj,pzi);
  return 0;
}