Pagini recente » Cod sursa (job #2980496) | Cod sursa (job #3257706) | Cod sursa (job #1414477) | Cod sursa (job #2830611) | Cod sursa (job #1405390)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int n, maxim, ib, jb, start, sum;
int main()
{
fin >> n;
maxim = -int(2e9);
sum = 0;
for (int i = 1, x; i <= n; i++)
{
fin >> x;
if (sum < 0)
{
sum = x;
start = i;
}
else
sum += x;
if (sum > maxim)
{
maxim = sum;
ib = start;
jb = i;
}
}
fout << maxim << " " << ib << " " << jb;
return 0;
}