Pagini recente » Cod sursa (job #1005900) | Cod sursa (job #2349068) | Cod sursa (job #1589862) | Cod sursa (job #99145) | Cod sursa (job #1474650)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("ssm.in");
ofstream g("ssm.out");
int main(){
int n, i, j, x, imax, jmax;
int s, smax;
f >> n;
i = imax = jmax = 1;
f >> s;
smax = s;
for (j = 2; j <= n; ++j){
f >> x;
if (s < 0) {
s = x;
i = j;
}
else
s += x;
if (s > smax) {
smax = s;
imax = i;
jmax = j;
}
}
g << smax << " " << imax << " " << jmax;
f.close();
g.close();
return 0;
}