public class Festival {
static int caseNum;
static int N, L;
static int timeArr[];
public static void main(String args[]) throws Exception {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
caseNum = Integer.parseInt(bufferedReader.readLine());
for (int i = 1; i <= caseNum; i++) {
String inputStr[] = bufferedReader.readLine().split(" ");
N = Integer.parseInt(inputStr[0]);
L = Integer.parseInt(inputStr[1]);
timeArr = new int[N + 1];
inputStr = bufferedReader.readLine().split(" ");
for (int j = 1; j <= N; j++) {
timeArr[j] = Integer.parseInt(inputStr[j - 1]);
}
double min = Double.MAX_VALUE;
double result = 0;
//L==N 바로 return
if (L == N) {
for (int n : timeArr) {
result += n;
}
min = result / L;
System.out.printf("%.12f", min);
return;
}
for (int j = L; j <= N; j++) {
for (int k = 1; k <= N; k++) {
result = 0;
for (int o = 0; o < j; o++) {
if (k + j <= N+1) {
result += timeArr[k + o];
}
}
result = result / j;
if (min > result && result != 0) {
min = result;
}
}
}
System.out.printf("%.12f\n", min);
}
}
naruro
package festival;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Festival {
static int caseNum;
static int N, L;
static int timeArr[];
}
8년 전