Cod sursa(job #1252958)

Utilizator sunt_emoSunt emo sunt_emo Data 31 octombrie 2014 17:12:32
Problema Subsecventa de suma maxima Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.36 kb
#include <fstream>

int main()
{
  std::ifstream in("ssm.in");
  std::ofstream out("ssm.out");
  int t, n, of = -1, s = -1, bs = -1000000000, bl, br;
  in >> n;
  for (int i = 1; i <= n; i++)
  {
    in >> t;
    s < 0 ? s = t, of = i : s += t;
    s > bs ? bs = s, bl = of, br = i : s;
  }
  out << bs << ' ' << bl << ' ' << br << '\n';
  in.close(), out.close();
}