Suppose that NTU has decided to revise the calculation of GPA. The new calculation method is explained as below.
| grade | semester GPA score | average original score (round to the nearest integer) |
| A+ | 4.3 | 90-100 |
| A | 4.0 | 85-89 |
| A- | 3.7 | 80-84 |
| B+ | 3.3 | 77-79 |
| B | 3.0 | 73-76 |
| B$$$-$$$ | 2.7 | 70-72 |
| C+ | 2.3 | 67-69 |
| C | 2.0 | 63-66 |
| C- | 1.7 | 60-62 |
| F | 0 | 0-59 |
The first line contains one integer $$$N\,(1 \leq N \leq 100)$$$ — the number of required courses.
The second line contains $$$N$$$ integers $$$a_1, a_2, ..., a_N \, (0 \leq a_1, a_2, ..., a_N \leq 100)$$$ — the estimated scores of each courses in order.
The third line also contains $$$N$$$ integers $$$b_1, b_2, ..., b_N \, (1 \leq b_1, b_2, ..., b_N \leq 5)$$$ — the credits of each courses in order.
The fourth line contains one integer $$$K\,(1 \leq K \leq N)$$$ — the number of semesters.
Output the highest possible final GPA score of Gareth's university career. Answers within $$$10^{-6}$$$ of the correct answer will be accepted as correct.
3 70 80 75 3 1 4 2
3.0000000
6 30 95 65 75 55 80 1 1 1 1 1 1 3
2.5666667
For the first example, the best way to take the three courses in exactly two semesters is to take the first two courses in the first semester and take the third course in the second semester. Then, the average original score of the first semester is $$$\frac{70\times 3+80\times 1}{3+1} = 72.5$$$ and the average original score of the second semester is $$$\frac{75\times 4}{4} = 75$$$. Therefore, the semester GPA scores for the two semesters are both $$$3.0$$$. Finally, the final GPA score of his university career is the unweighted average of the two semester GPA scores, $$$\frac{3.0+3.0}{2} = 3.0$$$.