Cod sursa(job #2320297)
Utilizator | Data | 14 ianuarie 2019 16:53:06 | |
---|---|---|---|
Problema | Secventa 2 | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include<fstream>
std::ifstream f("secv2.in");
std::ofstream g("secv2.out");
long long s=0,maxx=-2147483647;
int n,k,v[50005],i,nr,startc,start,stop;
int main()
{
f>>n>>k;
for(i=0;i<n;i++)
{
f>>nr;
s+=nr;
if(s<0)
{
s=0;
startc=i;
}
if(s>maxx)
{
maxx=s;
start=startc;
stop=i;
}
}
g<<start+2<<" "<<stop+1<<" "<<maxx;
f.close();
g.close();
return 0;
}