forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwoodcutting.cpp
48 lines (37 loc) · 837 Bytes
/
woodcutting.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
45
46
47
48
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
ll cases;
cin >> cases;
while(cases--) {
ll c;
cin >> c;
vector<ld> v;
for(ll i = 0; i < c; i++) {
ll nums;
cin >> nums;
ld total = 0;
for(ll i = 0; i < nums; i++) {
ld temp;
cin >> temp;
total += temp;
}
v.push_back(total);
}
sort(v.begin(), v.end());
ld sum = 0;
ld ans = 0;
for(ll i = 0; i < v.size(); i++) {
sum += v[i];
ans += sum;
}
ans /= v.size();
cout << fixed;
cout.precision(9);
cout << ans << endl;
}
}