Cod sursa(job #286500)
Utilizator | Data | 23 martie 2009 21:01:15 | |
---|---|---|---|
Problema | Secventa 2 | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.62 kb |
#include<fstream>
using namespace std;
ifstream fin("secv2.in");
ofstream fout("secv2.out");
long n,a[50001],s,maxx=-200000,k,i0,j0;
int main()
{ long i;
fin>>n>>k;
i0=1;
for(i=1;i<=n;i++)
{ fin>>a[i];
s+=a[i];
if(maxx<s) { maxx=s;
i0=i;
}
}
s=0;
maxx=-200000;
for(i=i0;i>=1;i--)
{ s+=a[i];
if(maxx<s) { maxx=s;
j0=i;
}
}
fout<<j0<<" "<<i0<<" "<<maxx;
fin.close();
fout.close();
return 0;
}