Pagini recente » Cod sursa (job #141455) | Cod sursa (job #2321516) | Cod sursa (job #2606235) | Cod sursa (job #2138443) | Cod sursa (job #900033)
Cod sursa(job #900033)
#include <stdio.h>
using namespace std;
long long N, K, sc, smax, st, dr, aux, i, val;
int main(){
freopen("secv2.in", "r", stdin);
freopen("secv2.out", "w", stdout);
scanf("%lld%lld", &N, &K);
smax = -(1<<60) - 1;
for(i = 1; i <= N; i++){
scanf("%lld", &val);
if(sc < 0){
sc = val;
aux = i;
}else{
sc += val;
}
if(smax < sc){
if((i - aux + 1) >= K){
smax = sc; st = aux; dr = i;
}
}
}
printf("%lld %lld %lld", st, dr, smax);
}