Cod sursa(job #3359499)
| Utilizator | Data | 29 iunie 2026 12:37:18 | |
|---|---|---|---|
| Problema | Subsecventa de suma maxima | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("ssm.in");
ofstream out("ssm.out");
int main()
{
int n, x;
in >> n;
int current, maxo;
in >> x;
current = maxo = x;
for(int i = 2; i <= n; i++)
{
in >> x;
current = max(current + x, x);
maxo = max(maxo, current);
}
out << maxo;
return 0;
}
