Pagini recente » Monitorul de evaluare | Borderou de evaluare (job #3327842) | Monitorul de evaluare | Cod sursa (job #3318239) | Cod sursa (job #3328754)
#include <fstream>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int main()
{
int n, i, x, s, st, s_max, st_max, dr_max;
fin >> n >> x;
s = s_max = x;
st = st_max = dr_max = 1;
for (i = 2; i <= n; i++) {
fin >> x;
if (s >= 0) {
s = s + x;
} else {
s = x;
st = i;
}
if (s > s_max) {
s_max = s;
st_max = st;
dr_max = i;
}
}
fout << s_max << " " << st_max << " " << dr_max << "\n";
return 0;
}