Pagini recente » Cod sursa (job #1658781) | Cod sursa (job #3320036) | Cod sursa (job #1122438) | Cod sursa (job #3273115) | Cod sursa (job #3332490)
#include <bits/stdc++.h>
#define int long long
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int n;
signed main()
{
fin >> n;
int l, r, max, curl, curmax;
fin >> curmax;
curl = 1;
l = curl, r = 1, max = curmax;
for(int i = 2; i <= n; i++)
{
int x; fin >> x;
if(curmax > 0)
{
curmax += x;
if(curmax > max)
{
r = i;
l = curl;
max = curmax;
}
}
else{
curmax = x;
curl = i;
if(curmax > max)
{
l = r = i;
max = curmax;
}
}
}
fout << max << " " << l << " " << r;
return 0;
}