#B4049. Compute Average Awarded Score Based on Classroom Participation
Compute Average Awarded Score Based on Classroom Participation
Compute Average Awarded Score Based on Classroom Participation
In a university, there are \(n\) courses. For course \(i\), there are \(p_i\) students enrolled with student IDs \(id_{i,1}, id_{i,2}, \ldots, id_{i,p_i}\) provided in ascending order. Each student has a corresponding classroom participation score \(sc_{i,1}, sc_{i,2}, \ldots, sc_{i,p_i}\), where the student with the smallest ID gets \(sc_{i,1}\) and so on.
The teacher awards a score for this course based on the classroom participation ranking: the student with rank \(j\) will receive \(w_{i,j}\) points. Note that the ranking is defined as:
\[ \text{rank} = \#\{\text{scores greater than } sc\} + 1, \]
For example, given classroom participation scores \(30, 30, 10, 20, 50\), both students with score \(30\) have rank \(2\).
Given a student ID \(ID\), compute the average score obtained by the student across the courses in which she is enrolled. If the average score is an integer, output it directly; otherwise, output it in the form a+b/c
, where \(a\) is the integer part and \(\frac{b}{c}\) is the irreducible fraction representing the fractional part.
inputFormat
The input consists of several lines:
- The first line contains a single integer \(n\), the number of courses.
- For each course, the following four lines are given:
- An integer \(p_i\) representing the number of students enrolled in the course.
- \(p_i\) space-separated integers representing the student IDs in ascending order.
- \(p_i\) space-separated integers representing the classroom participation scores \(sc_{i,1}, sc_{i,2}, \ldots, sc_{i,p_i}\) corresponding to the student IDs.
- \(p_i\) space-separated integers \(w_{i,1}, w_{i,2}, \ldots, w_{i,p_i}\), where \(w_{i,j}\) is the score awarded to the student with ranking \(j\).
- The final line contains a single integer \(ID\), the student ID of interest.
outputFormat
Output the average score of the courses in which the student with ID \(ID\) is enrolled. If the average is an integer, output it directly. Otherwise, output it in the form a+b/c
, where \(a\) is the integer part and \(\frac{b}{c}\) is the irreducible fraction for the fractional part.
sample
2
3
1001 1002 1003
80 70 90
10 5 1
2
1001 2002
60 100
20 10
1001
7+1/2