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