Pagini recente » Cod sursa (job #888287) | Cod sursa (job #1812606) | Cod sursa (job #3131762) | Cod sursa (job #2870690) | Cod sursa (job #291961)
Cod sursa(job #291961)
#include<fstream.h>
int main()
{
long long i,n,lmax,rmax,l,r;
long long s,max,x;
ifstream f("ssm.in");
f>>n;
max=1;
max=(long long)-1*max<<33;
s=0;
for (i=1;i<=n;i++)
{
f>>x;
if (s>0) s+=x;
else {
l=i;
s=x;
}
if (s>max) {
max=s;
lmax=l;
rmax=i;
}
}
ofstream g("ssm.out");
g<<max<<' '<<lmax<<' '<<rmax;
g.close();
f.close();
return 0;
}