Cod sursa(job #345596)

Utilizator aghamatMorariu Razvan aghamat Data 3 septembrie 2009 18:36:23
Problema Subsecventa de suma maxima Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.52 kb
#include <stdio.h>

int main()
{
    freopen("ssm.in","r",stdin);
    freopen("ssm.out","w",stdout);
    int n, s=0, min=0, best=99999999, pi=1, ps, pd, x;
    scanf("%d", &n);
     for (int i=1;i<=n;++i)
     {
          scanf("%d", &x);
          s=s+x;
          if (s - min > best)
               best = s - min,
               ps = pi+1,
               pd = i;
          if (s < min)
               min = s;
               pi = i;
     }

     printf("%d %d %d\n", best,ps,pd);
     return 0;
 
    }