cswork / OA打开练习工作台

NetflixOA #2

Rank Movies by Similarity Score (FrontEnd :)

估计简单可在线判题

考点(AI 标注)单调栈与堆原地数组

The similarity of each movie to the target movie is known. The score of a movie group is the sum of the k highest similarities in the group. Return the scores in the input order of the groups, without reordering the groups.

输入格式

The first line contains N G k; the second line contains N similarities; then G lines follow, each giving the group size m followed by m 0-based movie indices. This site uses N≤100000 and G≤10000, both ≥1; 1≤k≤m≤N, the indices within each group are distinct and valid, and the total number of members over all groups is ≤200000. Scores are in [0,1] with at most 6 decimal places, given as plain decimal input.

输出格式

First output G, then output the G group scores, which may be on separate lines. Each value may have an absolute or relative error of 1e-5; equivalent integers, decimals, and scientific notation are accepted, and no fixed number of decimal places is required.

样例 1

输入:

5 2 2
0.300000 0.200000 0.100000 0.400000 0.500000
3 1 2 4
3 0 3 4

输出:

2
0.700000 0.900000

样例 2

输入:

3 2 1
1.000000 0.000000 0.500000
3 0 1 2
2 1 2

输出:

2
1.000000 0.500000

样例 3

输入:

3 2 3
0.000001 0.000002 0.999999
3 0 1 2
3 2 1 0

输出:

2
1.000002 1.000002

样例说明

Example 1: the top two values of the two groups are 0.5+0.2=0.7 and 0.5+0.4=0.9, keeping the group order. Example 2: k=1, and the maxima of the two groups are 1 and 0.5. Example 3: k equals the group size, so both groups add all three values to get 1.000002; the order within a group does not affect the score.