U

16. Student Pass or Fail Evaluator

Easy

Problem Description

Given a student's name and their scores in three exams: s1,s2,s3s_1, s_2, s_3. Calculate their average score truncated (rounded down) to the nearest integer.

The student passes (PASS) if and only if:

  1. 1.Their integer average is ≥50\ge 50, AND
  2. 2.Every individual subject score is ≥40\ge 40.

Otherwise, the student fails (FAIL).

Input Format

  • •Line 1: A single-word string name (without spaces).
  • •Line 2: Three space-separated integers s1,s2,s3s_1, s_2, s_3 (0≤si≤1000 \le s_i \le 100).

Output Format

Print a single line containing name, the integer average score, and the result (PASS or FAIL), separated by spaces.

Example 1:
Input:
Alice
85 90 78
Output:
Alice 84 PASS
Explanation: Average = (85 + 90 + 78) / 3 = 253 / 3 = 84. Average >= 50 and all scores >= 40, so PASS.
Example 2:
Input:
Bob
35 95 90
Output:
Bob 73 FAIL
Explanation: Average = 220 / 3 = 73 >= 50, but subject 1 score is 35 < 40, so FAIL.
Example 3:
Input:
Charlie
45 45 45
Output:
Charlie 45 FAIL
Explanation: All scores >= 40, but average is 45 < 50, so FAIL.
Constraints:
  • 1 <= length(name) <= 50
  • 0 <= s1, s2, s3 <= 100
  • Time complexity target: O(1)
  • Auxiliary space target: O(1)
Follow up:How would you extend this to handle a dynamic list of N subjects with weighted credits?
1,180 Online