Pagini recente » Cod sursa (job #1080483) | Cod sursa (job #1736517) | Cod sursa (job #1732019) | Cod sursa (job #1744249) | Cod sursa (job #1893812)
#include <fstream>
using namespace std;
ifstream in("ssm.in");
ofstream out("ssm.out");
int smax = -2000000000, lmax, pmax;
int main() {
int n, x, s = 0;
in >> n;
for (int i = 1; i <= n; ++i) {
in >> x;
if (s + x > x) {
s += x;
if (s > smax) {
smax = s;
pmax = i;
lmax++;
}
} else {
s = x;
if (s > smax) {
smax = s;
pmax = i;
lmax = 1;
}
}
}
out << smax << " " << pmax - lmax << " " << pmax;
return 0;
}