반응형
#include<stdio.h>
int main()
{
int n, k, x = 0;
int arr[50001],p[50001];
double max = 0;
int sum = 0;
double temp = 0;
scanf("%d %d\n",&n,&k);
for (int i = 0; i < n; i++)
{
scanf("%d", &arr[i]);
sum += arr[i];
p[i] = sum;
}
for (int i = k; i <= n; i++)
{
for (int j = i; j < n; j++)
{
temp = double(p[j] - p[j - i]) / i;
if (temp > max)
{
max = temp;
}
}
for (int j = k; j <= n; j++)
{
temp = double(p[j - 1]) / j;
if (temp > max)
{
max = temp;
}
}
}
printf("%.12f", max);
return 0;
}
https://codeforces.com/contest/1003/problem/C
Problem - C - Codeforces
codeforces.com
반응형
'🧩PS > 🥈Nomal' 카테고리의 다른 글
[C/C++] Codeforce 158B - Taxi (0) | 2020.04.04 |
---|---|
[C/C++] Codeforce 160A - Twins (0) | 2020.04.04 |
[C/C++] Codeforce 466C - Number of Ways (0) | 2020.04.04 |
[C/C++] Codeforce 734B - Anton and Digits (0) | 2020.04.04 |
[C/C++] Codeforce 1285B - Just Eat It! (0) | 2020.04.04 |