Pagini recente » Diferente pentru problema/dfs intre reviziile 4 si 22 | Cod sursa (job #292134) | Cod sursa (job #3210646) | Cod sursa (job #1573439) | Cod sursa (job #291956)
Cod sursa(job #291956)
#include<fstream.h>
int main()
{
long i,n,lmax,rmax,l,r;
long long s,max,x;
ifstream f("ssm.in");
f>>n;
max=-1;
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;
}