Cod sursa(job #1136199)
Utilizator | Data | 8 martie 2014 21:50:28 | |
---|---|---|---|
Problema | Secventa 2 | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <fstream>
using namespace std;
ifstream f("secv2.in");
ofstream q("secv2.out");
int j,x,n,k,i,s,aux1,hh,start,m=-26000;
int main()
{
f>>n>>k;
j=1;
start=1;
s=0;
for (i=1;i<=n;i++)
{
f>>x;
if (s<0){s=x;start=i;hh=i;}
else{s=s+x; hh++;}
if ((s>m) && (hh>=k)){m=s; aux1=start; j=hh; }
}
q<<aux1<<" "<<j<<" "<<m;
f.close();
q.close();
}