Use an array formula. If the max marks are in D4-F4 and the student's marks are in D9-F9, then

The student's total is =SUM(D9:F9)

The max possible value is =SUM(IF(ISBLANK(D9:F9),0,D4-F4))

Remember that array formulas require Ctrl-Shift-Enter. If the entire formula is not enclosed in braces ({ and }), then it was not entered properly.