Pagini recente » Cod sursa (job #3333902) | Cod sursa (job #3335482) | Cod sursa (job #3333893) | Cod sursa (job #3333897) | Cod sursa (job #3338501)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int main() {
int n;
fin >> n;
int p = 1, u = 1;
int s = 0, smax = -2000000000;
int startSecvCurenta = 1;
for (int i = 1; i <= n; i++) {
int x;
fin >> x;
if (s < 0) {
s = 0;
startSecvCurenta = i;
}
s += x;
if (smax < s) {
smax = s;
u = i;
p = startSecvCurenta;
}
}
fout << smax << " " << p << " " << u;
return 0;
}