Cod sursa(job #581499)
| Utilizator | Data | 14 aprilie 2011 11:49:47 | |
|---|---|---|---|
| Problema | Subsecventa de suma maxima | Scor | 85 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include<cstdio>
int s,maxx=(1<<31)-1;
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;
maxx*=-1;
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;
}
