Pagini recente » Cod sursa (job #1426588) | Cod sursa (job #579159) | Cod sursa (job #1148212) | Cod sursa (job #87228) | Cod sursa (job #2813415)
#include <iostream>
#include <fstream>
using namespace std;
#define INF 20000000000
int main()
{
ifstream fin("secv2.in");
ofstream fout("secv2.out");
long long n, k;
fin >> n >> k;
long long sc = -1;
long long smax = -INF;
long long st = 1;
long long stmax, drmax;
long long lc = 0;
for(long long i = 1; i <= n; i++){
long long x;
fin >> x;
if(sc < 0){
sc = x;
st = i;
lc = 1;
}else{
sc+=x;
lc++;
}
if(lc >= k && sc > smax){
smax = sc;
stmax = st;
drmax = i;
}
}
fout << stmax << " " << drmax << " " << smax;
fin.close();
fout.close();
return 0;
}