🧩PS/🥈Nomal
[C/C++] Codeforce 1003C - Intense Heat
Cocoon_
2020. 4. 4. 05:54
반응형
#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
반응형