Pagini recente » Cod sursa (job #1159515) | Cod sursa (job #2737080) | Cod sursa (job #424870) | Cod sursa (job #2254736) | Cod sursa (job #2670047)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ssm.in");
ofstream fout("ssm.out");
int x=-2000000005, n, ind1, ind2, s, i, smax, ind1max, ind2max, nrmax;
int main()
{
fin >> n;
ind1=1;
for(i=1;i<=n;i++)
{
fin >> x;
ind2=i;
if(x>nrmax)
{
nrmax=x;
}
if(s<0)
{
s=x;
if(s>smax)
{
smax=s;
ind1max=ind1;
ind2max=ind2;
}
ind1=i;
}
else
{
s=s+x;
if(s>smax)
{
smax=s;
ind1max=ind1;
ind2max=ind2;
}
}
}
if(nrmax<0)
fout << nrmax << " " << ind2max << " " << ind2max;
else
fout << smax << " " << ind1max << " " << ind2max;
return 0;
}