Cod sursa(job #986877)
| Utilizator | Data | 19 august 2013 17:37:57 | |
|---|---|---|---|
| Problema | Secventa 2 | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <cstdio>
using namespace std;
long n,i,sc,st=1,smax,drmax,stmax,k;
long v[6000001];
int main()
{
freopen("secv2.in","r",stdin);
freopen("secv2.out","w",stdout);
scanf("%ld%ld",&n,&k);
for(i=1;i<=n;i++)
scanf("%ld",&v[i]);
for(i=1;i<=n;i++)
{
if(sc<=0)
{
st=i;
sc=v[i];
}
else
sc=sc+v[i];
if(sc>=smax)
{
smax=sc;
stmax=st;
drmax=i;
}
}
printf("%ld %ld %ld\n",stmax,drmax,smax);
return 0;
}
