Skating panel scores
EasyOnline Assessment
Compute the per-element scores and the total for a figure-skating program, where the judges' extreme marks are trimmed.
A program is a list of elements (jumps, spins, steps). Each element has a weight (how much it is worth) followed by the marks given by the judges' panel. A mark is an integer from 0 to 100, or -1 if that judge did not score the element; -1 entries are ignored entirely, as if the judge were not on the panel for that element.
To score an element:
- Remove the ignored
-1marks. - If five or more marks remain, drop exactly one lowest mark and exactly one highest mark (if the lowest or highest value appears several times, only one copy of each is dropped). With fewer than five marks, nothing is dropped.
- The element's score is
weight × (average of the remaining marks), rounded to the nearest integer, with an exact half rounded up. - If no marks remain, the element scores 0.
Each element is rounded on its own; the total is the sum of the rounded element scores.
Input: elements, a list where each entry is [weight, mark, mark, ...].
Output: a list of integers: the score of each element in the given order, followed by the total as the last entry. For an empty program return [0].
Example 1
- Input:
- [[[2,80,90,90,70,90,60,90],[1,50,60,70]]]
- Output:
- [168,60,228]
- Explanation
- The first element has marks 80, 90, 90, 70, 90, 60, 90 (seven judges). The lowest (60) and one highest (90) are dropped; the other three 90s stay. The kept marks 80, 90, 90, 70, 90 sum to 420, times weight 2 is 840, divided by 5 is 168. The second element has only three marks, so nothing is dropped: (50 + 60 + 70) = 180, times weight 1, divided by 3 = 60. The total is 228.
Example 2
- Input:
- [[[3,71,-1,72,73,74],[5]]]
- Output:
- [218,0,218]
- Explanation
- Five judges scored the first element but one entry is -1, so only four marks count and none are dropped: 71 + 72 + 73 + 74 = 290; times weight 3 is 870; 870 / 4 = 217.5, which rounds up to 218. The second element has no marks at all and scores 0. The total is 218.
Example 3
- Input:
- [[[1,100,50,51,0,50,51],[4,25]]]
- Output:
- [51,100,151]
- Explanation
- Six judges mark an element with weight 1 and the extremes 100 and 0 are dropped, leaving 50, 51, 50, 51 for an average of 50.5, which rounds up to 51. The element with weight 4 and the single mark 25 scores 100. The total is 151.
Constraints
0 <= elements.length <= 200- Each element is a list
[weight, mark, mark, ...]with1 <= weight <= 10followed by0to15marks - Each mark is an integer from
0to100, or-1when a judge did not score that element