-
Notifications
You must be signed in to change notification settings - Fork 0
/
festival.cpp
44 lines (35 loc) · 905 Bytes
/
festival.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
double solve(int day, int team, vector<int>& price) {
double ret = 99999.;
int sum = 0;
for (int count = team; count <= day; ++count) {
for (int i = 0; i + count <= day; ++i) {
sum = 0;
for (int j = 0; j < count; ++j) {
sum += price[i + j];
}
ret = min(ret, (double) sum / count);
}
}
return ret;
}
int main() {
int numTestCase;
cin >> numTestCase;
for (int i = 0; i < numTestCase; ++i) {
int numDay;
cin >> numDay;
int numTeam;
cin >> numTeam;
vector<int> price(numDay);
for (int j = 0; j < numDay; ++j) {
cin >> price[j];
}
printf("%.8lf\n", solve(numDay, numTeam, price));
}
return 0;
}