Cod sursa(job #1894978)

Utilizator ChiriGeorgeChiriluta George-Stefan ChiriGeorge Data 27 februarie 2017 18:25:01
Problema Subsecventa de suma maxima Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.45 kb
#include <fstream>
#include <queue>
using namespace std;

ifstream fin("ssm.in");
ofstream fout("ssm.out");

int i, n, x, l, r, best[40000], best_max;

int main()
{
    fin >> n;
    for(i = 1; i <= n; i++)
    {
        fin >> x;
        best[i] = x;
        if(best[i] < best[i-1] + x)
            best[i] = best[i-1] + x;
        if(best_max < best[i])
            best[i] = best_max;
    }
    fout << best_max;
    return 0;
}