Problem Statement
Wolf Sothe has made an online judge website called Wolf Online Judge. He came up with a special scoring system.
In this scoring system, the score value of a problem depends on how many coders solve the problem. This value can be calculated as 64.0/(the number of coders who solved the problem) if at least one coder solved it, and 0 otherwise. The total score of each coder is the sum of score values of all problems that the coder solved.
You are given a String[] solved with N elements, where N is the number of coders. Each element of solved contains M characters, where M is the number of problems. If the j-th character of the i-th element of solved is 'Y', the i-th coder solved the j-th problem; if it's 'N' instead, the i-th coder didn't solve the j-th problem.
Compute and return a double[] with N elements. The i-th element of this double[] is equal to the i-th coder's total score.
In this scoring system, the score value of a problem depends on how many coders solve the problem. This value can be calculated as 64.0/(the number of coders who solved the problem) if at least one coder solved it, and 0 otherwise. The total score of each coder is the sum of score values of all problems that the coder solved.
You are given a String[] solved with N elements, where N is the number of coders. Each element of solved contains M characters, where M is the number of problems. If the j-th character of the i-th element of solved is 'Y', the i-th coder solved the j-th problem; if it's 'N' instead, the i-th coder didn't solve the j-th problem.
Compute and return a double[] with N elements. The i-th element of this double[] is equal to the i-th coder's total score.
Definition
- Class:
- WolfOnlineJudge
- Method:
- score
- Parameters:
- String[]
- Returns:
- double[]
- Method signature:
- double[] score(String[] solved)
- (be sure your method is public)
Notes
- Your return value must have absolute or relative error smaller than 1e-9.
Constraints
- The number of elements in solved will be between 1 and 50, inclusive.
- Each element in solved will have the same number of characters.
- The length of each element in solved will be between 1 and 50, inclusive.
- Every character will be either 'Y' or 'N'.
Examples
{"YYNY","NYNY","NNNY"}Returns: {117.33333333333333, 53.33333333333333, 21.333333333333332 }There are three coders and four problems. The first problem was solved by one wolf, so its score value is 64pts. The second problem was solved by 2 wolves, so its score value is 64/2 = 32pts. No wolves solved the third problem, so we can ignore it. The fourth problem was solved by 3 wolves, so its score value is 64/3 = 21.33333...pts.{"YYYN","YYNN","YYYN","NNNY","YYYY","YNYY","NNNN"}Returns: {44.8, 28.8, 44.8, 21.333333333333332, 66.13333333333333, 50.13333333333333, 0.0 }{"NNNNNNN","NNNNNNN","NNNNNNN","NNNNNNN","NNNNNNN","NNNNNNN","NNNNNNN"}Returns: {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }The problem set is too difficult, so no wolves got positive score.{"YYYYN","YYYYN","YYYYN","NNNNY","YYYYN","YYYYN","YYYYN"}Returns: {42.666666666666664, 42.666666666666664, 42.666666666666664, 64.0, 42.666666666666664, 42.666666666666664, 42.666666666666664 }A wolf that solved less problems can get a higher score than a wolf that solved more problems.{ "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNYNNNNNNNNNYNNNNNYNYNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNYNNNNNNNNNYNNNNNYNYNNNYYYYYYYYYYYYYNNNNNN", "NNNYYYYYYYYYYYNNYYYYYYYNNYNYNNNNNNNNYNNNNNNNNNNNNN", "NNNNNNNNNYNNNNNNNNNYNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNYYYNNNNNNNNNYNNNYYYYYNNNNNNYYYYYYYNNNNNNNNN", "NNNNNNNYNYNNNNNNNNYNNNYNNNNNNNNNNYYNNNNNNYYNNNNNNN", "NNNNNNNYYYNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNYNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNYNNNNNNNYNNNYNNNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNYNNNNNNNYNNNNNYYYYYYNNNNNNNYYYYYYYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNYNNNNNNNNN", "NNNNN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NNNNNNNNN", "NNNYNNYNNYNNNNYNNNNNYYNYNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNYNNNYYNNNNNYNNNNYNNNNYNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNYYYNYNNNYYNNNNNYNNNNNYYYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNYNNNNNYNNNNNNYNNNNNNYYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNYNNNNNYNNNNNNYYNNNNNNYYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNYNNNNYNNNNNYYYNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYYYNNNNNNYYYYNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN" }Returns: {0.0, 36.034188034188034, 221.17704517704522, 257.6214896214896, 22.476190476190474, 162.17631257631257, 106.13333333333333, 62.47619047619047, 37.33333333333333, 48.0, 172.84297924297923, 0.0, 0.0, 28.8, 23.46666666666667, 340.94456654456667, 12.8, 55.46666666666667, 19.91111111111111, 15.58974358974359, 9.846153846153847, 4.923076923076923, 4.923076923076923, 4.923076923076923, 9.846153846153847, 15.58974358974359, 19.91111111111111, 55.46666666666667, 0.0, 0.0, 0.0, 36.8, 94.65396825396824, 52.266666666666666, 78.93333333333334, 105.06666666666666, 79.66593406593405, 112.37704517704518, 0.0, 16.253968253968253, 17.77777777777778, 19.91111111111111, 48.3008547008547, 53.22393162393162, 54.7008547008547, 105.38901098901098, 0.0, 0.0, 0.0, 0.0 }