Share of workers above the average
Statement
A workshop leaves one line of record every time a job finishes. Each record holds the number of workers who took part in that job and the number of items each worker made. The number of workers who took part differs from record to record.
The owner of the workshop wants to take the average of the counts the workers made in each record, and to find what percent of the workers made more than that average. The average is the sum of the counts written in that record divided by the number of workers, and it becomes a fraction when the division does not come out even. The share of workers above the average is the number of such workers divided by the number of workers, times 100. A worker who made exactly the average does not count as being above it.
Given T records in total, write a program that prints the share of workers above the average for each record in order.
For example, suppose T=2 records are given. The first record has 2 workers, who made 98 and 43 items in order. The second record has 4 workers, who made 25, 89, 3, and 67 items in order. Taking the sum and the average of each record and then finding the workers above the average gives the table below.
| Record number | Workers | Counts made | Sum | Average | Counts above the average | Workers above |
|---|---|---|---|---|---|---|
| 1 | 2 | 98, 43 | 141 | 70.5 | 98 | 1 |
| 2 | 4 | 25, 89, 3, 67 | 184 | 46 | 89, 67 | 2 |
In the first record 1 worker out of 2 is above the average, so the share is 50 percent. In the second record 2 workers out of 4 are above the average, so the share is 50 percent as well. Writing the two values to three decimal places gives the following.
| Record number | 1 | 2 |
|---|---|---|
| Share | 50.000% | 50.000% |
In a record with only 1 worker, the count that one person made is the average itself. A worker who made exactly the average is not counted, so no worker is above the average and the share becomes 0.000%.
Input and Output Examples
Example 1
Input
2 2 98 43 4 25 89 3 67
Output
50.000% 50.000%
Example 2
Input
1 1 19
Output
0.000%
Example 3
Input
3 30 32 55 4 3 81 39 56 6 66 40 57 95 10 19 86 40 93 14 67 37 77 28 71 15 35 77 55 1 21 90 5 72 16 37 10 9 31 94 97 99 38 86 24 61 59 25 70 14 35 32 71 38 75 22 94 14 7 14 16 97 72 84 22 77 64 41 2 31
Output
46.667% 40.000% 48.387%
Input
First, the number of records T is given on the first line. T is a natural number between 1 and 20.
Next, over T lines, each record is given in order. Each line first gives the number of workers n who took part in that job, and after it the numbers of items the n workers made, in order, separated by spaces. So each line holds n+1 numbers in all. n is a natural number between 1 and 50, and each count made is an integer between 0 and 100.
Output
Print T lines. The i-th line holds the share of workers above the average in the i-th record. Write the share to three decimal places, rounding at the fourth decimal place. Attach one percent sign after the value. Even when the share is 0, do not drop the decimal places, and write it in the form 0.000%.
Requirements
- Read the input from standard input and write the answer to standard output
- The first number on each record line is the number of workers, not a count of items made
- A worker who made exactly the average does not count as being above it
- Write the share to three decimal places and attach
%after it. The places have to be filled in, as in0.000% - Grading compares the output with the expected value down to the last character
- You must write a program that reads from standard input and writes to standard output
- Trailing spaces at the end of a line and blank lines at the end of the output are ignored when grading
- The languages you can use are Python and JavaScript
- The memory limit is 256MB. The browser does not measure it, it only states it
- The time limit is set by measuring the setter's reference solution on the same runtime
- On this problem you submit code, not a prompt. That code runs in the browser on this device, and all that goes to the server is a fingerprint of the output and the time it took. Whether it is correct is decided by the server. The run time is a number each device reports, so the code and the device details are posted next to it on the leaderboard.
- There are 15 cases, and 3 of them show the input together with the expected output. The rest are used only when you submit and are not shown on this page.
- You have to pass all 15 cases to solve this.
Examples
3 public cases. Judging also uses hidden cases. You have to pass all 15 cases to solve this.
1 1 19
0.000%
2 2 98 43 4 25 89 3 67
50.000% 50.000%
3 30 32 55 4 3 81 39 56 6 66 40 57 95 10 19 86 40 93 14 67 37 77 28 71 15 35 77 55 1 21 90 5 72 16 37 10 9 31 94 97 99 38 86 24 61 59 25 70 14 35 32 71 38 75 22 94 14 7 14 16 97 72 84 22 77 64 41 2 31
46.667% 40.000% 48.387%
Solution
Your code runs on this device. Only the fingerprint of the output and the elapsed time go to the server. The server decides whether it is correct.
Submitting requires you to log in. Running against the public cases works without one.
You can test with 3 public cases. Submitting runs the hidden cases too.
People who solved this problem
Nobody yet. You could be the first.