Pagini recente » Cod sursa (job #2185210) | Cod sursa (job #1322434) | Cod sursa (job #1352710) | Cod sursa (job #3003937) | Cod sursa (job #2320307)
#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;
}
}
if(stop+1-start+2>=k)
g<<start+2<<" "<<stop+1<<" "<<maxx;
else
g<<0;
f.close();
g.close();
return 0;
}