Pagini recente » Cod sursa (job #296170) | Cod sursa (job #586554) | Borderou de evaluare (job #2614761) | Cod sursa (job #3314331) | Cod sursa (job #3343355)
//#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
string file = "ssm";
ifstream f(file + ".in");
ofstream g(file + ".out");
int main()
{
long long n, x, i, sum = 0, st = 1, stmax = 0, drmax = 0, maxx = -2000000000;
f >> n;
for (i = 1; i <= n; i++)
{
f >> x;
if (sum < 0)
sum = x, st = i;
else
sum += x;
if (sum > maxx) {
maxx = sum;
stmax = st;
drmax = i;
}
}
g << maxx << " " << stmax << " " << drmax;
return 0;
}