Untitled
raw download clone
C
views 21
,
size 569 b
#include<stdio.h>
#define Max(a,b) ((a>b)?a:b)

double a[5001]= {0};

int main(void)
{
    int n,k;
    double max=0;

    scanf("%d%d",&n,&k);
    for(int i=1; i<=n; i++)
    {
        scanf("%lf",&a[i]);
        a[i]+=a[i-1];
        //printf("%d\n",a[i]);
    }
    for(int j=0; j<=n-k; j++)
    {
        for(int i=0; i<=n-k-j; i++)
        {
            max=Max(max,(a[k+i+j]-a[j])/(k+i));
            //printf("%.3llf\n",(a[k+i+j]-a[j])/(k+i));
        }
    }
    //printf("%lld\n",max);
    printf("%.3lf\n",max);

    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.