Cod sursa(job #2724512)

Utilizator KPP17Popescu Paul KPP17 Data 17 martie 2021 11:03:54
Problema Subsecventa de suma maxima Scor 95
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.33 kb
#include <fstream>
#define mF "ssm"
std::ifstream in(mF ".in");
std::ofstream out(mF ".out");
int main()
{
    int n, a = 1 << 31, x, y; in >> n;
    for (int i = 1, j = 1, b = 0; j <= n; j++)
        {int e; in >> e; b += e; if (a < b) a = b, x = i, y = j; if (b <= 0) i = j+1, b = 0;}
    out << a << ' ' << x << ' ' << y;
}