Cod sursa(job #581497)
| Utilizator | Data | 14 aprilie 2011 11:47:48 | |
|---|---|---|---|
| Problema | Subsecventa de suma maxima | Scor | 80 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include<cstdio>
int s,maxx=1<<31;
int ind,b,e,N;
inline void citire()
{
freopen("ssm.in","r",stdin);
freopen("ssm.out","w",stdout);
scanf("%d",&N);
ind=1;
int x;
for (int i=1; i<=N; ++i)
{
scanf("%d",&x);
if (s<0)
{
s=x;
ind=i;
}
else
s+=x;
if (maxx<s)
{
maxx=s;
b=ind;
e=i;
}
}
printf("%d %d %d",maxx,b,e);
}
int main()
{
citire();
return 0;
}
