Pagini recente » Cod sursa (job #865022) | Cod sursa (job #1865479) | Cod sursa (job #53062) | Cod sursa (job #1740610) | Cod sursa (job #1893811)
#include <fstream>
using namespace std;
ifstream in("ssm.in");
ofstream out("ssm.out");
int smax, 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;
}