#K551. Manage Attendance Records
Manage Attendance Records
Manage Attendance Records
You are given n students and each student has attendance records for 5 courses. Initially, every attendance value is 0. You need to process m operations. There are two types of operations:
I i j x
: Increase the attendance of student i in course j by an integer x.Q i
: Query the average attendance of student i across all 5 courses. The average should be computed as $$\text{average} = \frac{a_1 + a_2 + a_3 + a_4 + a_5}{5},$$ and printed with exactly 2 decimal places.
Input is given via standard input (stdin) and output should be printed to standard output (stdout). Make sure your solution reads from stdin and writes to stdout.
inputFormat
The first line contains two integers n
and m
, denoting the number of students and the number of operations, respectively. The next m
lines each contain an operation in one of the following formats:
I i j x
— Increase the attendance of student i for course j by x.Q i
— Query the average attendance of student i.
outputFormat
For each query operation (Q i
), output the average attendance of the specified student as a floating point number with exactly 2 decimal places. Each answer should be printed on its own line.
3 5
I 1 1 3
I 1 2 4
Q 1
I 2 5 5
Q 2
1.40
1.00
</p>