Pagini recente » Cod sursa (job #123095) | Cod sursa (job #478569) | Cod sursa (job #3333472) | Cod sursa (job #3301613) | Cod sursa (job #3335191)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
int n, s, smax = -2000000000, start, final, x, st_curent;
int main() {
f >> n;
start = 1;
for (int i = 1; i <= n; i++) {
f >> x;
s += x;
if (s > smax) smax = s, start = st_curent, final = i;
if (s < 0) s = 0, st_curent = i + 1;
}
g << smax << " " << start << " " << final;
return 0;
}