Pagini recente » Cod sursa (job #3338994) | Cod sursa (job #3340831) | Cod sursa (job #3339287) | Cod sursa (job #2330940) | Cod sursa (job #3339235)
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int n, x;
in >> n;
long long smax = -2000000000;
long long scrrnt = -1;
int bmax = 0, emax = 0, bcur = 1;
for (int i = 1; i <= n; i++) {
fin >> x;
if (scrrnt < 0) {
scrrnt = x;
bcur = i;
} else {
scrrnt += x;
}
if (scrrnt > smax) {
smax = scrit;
bmax = bcur;
emax = i;
}
}
fout << smax << " " << bmax << " " << emax;
return 0;
}