12135 - Ghoul Dawn
raw download clone
C
views 22
,
size 689 b
#include <stdio.h>

double max(double a, double b);

int main(void)
{
    int n, k, temp;
    double subans = 0, ans = 0;
    unsigned long long p[5001] = {0};

    scanf("%d%d", &n, &k);
    for(int i=1; i<=n; i++)
    {
        scanf("%d", &temp);
        p[i] = temp + p[i-1];
    }
    for(int j=k; j<=n; j++)
    {
        for(int l=j; l<=n; l++)
        {
            subans = max(subans, p[l] - p[l-j]);
            if(l == n)
                subans /= j;
        }
        ans = max(ans, subans);
    }
    printf("%.3lf\n", ans);

    return 0;
}

double max(double a, double b)
{
    if(a > b)
        return a;
    else
        return b;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.