#P3887. [GDOI2014] 世界杯

    ID: 2824 远端评测题 1000ms 250MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>2014各省省选广东排序优先队列队列

[GDOI2014] 世界杯

Description

The 3014 World Cup is about to begin! As the coach of the defending champion, the Chinese national football team, every player under your command is a powerhouse. Figuring out the strongest 11-player lineup is a happy kind of trouble.

As is well known, the 11 players in a football lineup are each assigned to a particular position, which are mainly divided into four types: goalkeeper, defender, midfielder, and forward. There is exactly one goalkeeper, and the number of defenders, midfielders, and forwards depends on the formation you set. A formation is expressed as AA-BB-CC from defenders to forwards, not counting the goalkeeper. For example, a 3-5-2 formation means there are three defenders, five midfielders, and two forwards. Due to fierce competition, each player is trained only for one position, so each person can play only one of the four positions.

As a coach who knows the players’ abilities inside out, you have quantified each player’s overall rating. To better arrange the formations, your coaching team decides to use the following strategy to assign players: first, propose QQ formations in order, representing the first formation, the second formation, …, the QQ-th formation. Then, for each formation, choose from the players not yet selected the best available numbers of goalkeeper(s), defenders, midfielders, and forwards. For example, for the first formation, select from all players; for the second formation, select from all players except those chosen for the first formation; for the third formation, select from all players except those chosen for the first and second formations; and so on.

Now that the QQ formations are fixed, what you need to know is the average overall rating for each formation.

Input Format

The first line contains four integers K,D,M,FK, D, M, F, representing the number of available goalkeepers, defenders, midfielders, and forwards.

The second line contains KK integers kik_i, representing the overall rating of each goalkeeper.

The third line contains DD integers did_i, representing the overall rating of each defender.

The fourth line contains MM integers mim_i, representing the overall rating of each midfielder.

The fifth line contains FF integers fif_i, representing the overall rating of each forward.

The sixth line contains an integer QQ, representing the number of formations proposed by the coaching team.

Each of the following QQ lines contains three integers Ai,Bi,CiA_i, B_i, C_i separated by spaces, indicating that the ii-th formation is the AiA_i-BiB_i-CiC_i formation.

Output Format

Output QQ lines. For the ii-th formation, output a real number representing the maximum possible average overall rating for that formation, rounded to 22 decimal places.

3 10 12 4
76 60 87
78 84 84 84 81 82 72 51 77 57
85 84 62 87 88 64 81 90 80 66 88 85
65 83 63 79
2
4 5 1
4 4 2
85.64
78.00

Hint

For 30%30\% testdata, K,D,M,F1000K, D, M, F \le 1000, Q10Q \le 10.

For 100%100\% testdata, 1K,D,M,F1051 \le K, D, M, F \le 10^5, 0ki,di,mi,fi1080 \le k_i, d_i, m_i, f_i \le 10^8, 1QK1 \le Q \le K, 0Ai,Bi,Ci100 \le A_i, B_i, C_i \le 10, Ai+Bi+Ci=10A_i + B_i + C_i = 10, AiD\sum A_i \le D, BiM\sum B_i \le M, CiF\sum C_i \le F.

Translated by ChatGPT 5