GPA1 - GRADE POINT AVERAGE

Every student of a college has to write 3 internal assessments and 1 final exam on each semester for all the 6 subjects. Each internal assessment mark is out of 20 and the final exam mark is out of 100. The best two of three assessment marks is chosen and those marks are considered to be out of 45. The final exam mark is considered to be out of 50. The remaining 5 marks is allotted based on the percentage of attendance of the student.

Attendance mark allotment

  • Below 51% attendance – 5 marks
  • Below 61% attendance – 4 marks
  • Below 71% attendance – 3 marks
  • Below 81% attendance – 2 marks
  • Below 91% attendance – 1 mark
  • else – No mark for those sincere students

Some students even bunk the assessments. If he bunks then instead of the mark ‘ab’ symbol is used which denotes “absent”. But no one bunks the final exam.

No attendance is taken during exam days

For each subject there’ll be some credit allotted by the department based on the importance of the subject.

  Total marks in a particular subject = best two out of three assessments (45%) + attendance mark (5%) + Final exam (50%)

Points out of 10:

%Total mark in a subject     Points
       >= 91                   10
       >= 81                    9
       >= 71                    8
       >= 61                    7
       >  50                    6
       == 50                    5
       <  50                    0

If the student scores 0 point in any of the subjects then he’s declared as FAILED else he’s declared as PASSED.

Mr. Chintumani, a professor of Computer Science department of the college designed a software program to calculate the GRADEPOINTAVERAGE (GPA) of the student and to determine whether the student is “PASSED” or “FAILED"

GPA = sum of (credit * points) for all the subjects / total number of credits of all the subjects

Input

The first line consists of an integer n, the number of students in the class. Then n test cases follows, in each test case the first line consists of 6 integers a, b, c, d, e and f, the credits of the 6 subjects. Then for the next 6 lines, each line (each subject) consists of 5 numbers (the first three numbers are the assessment marks out of 20, the fourth is the final exam mark and the fifth is the percentage of attendance).

Output

Assume you are Prof. Chintumani and print the result and GPA (rounded to two decimal places) per line for each student in the format as given in the example output.

Example:

Input:
1
1 1 1 2 2 3
19 18 20 70 70
17.33 15 16.66 66 70.66
ab ab ab 0 100
ab ab 10 78 78
17 18.33 19.5 64 87
14 8 ab 60 45

Sample Output:
FAILED, 6.30

Explanation of the testcase:

There is only 1 student

In the Subject 0, he got 19, 18 and 20 as internal marks, considering best two of three his internals score is 43.875/45.

His final exam score is 35/50.

His attendance mark is 3.

So the total marks he got in that subject is 81.875 which leads to 9 points.

Similarly he gets.

Subject 1: 74.2387 → 8 points

Subject 2: 0 → 0 points

Subject 3: 52.25 → 6 points

Subject 4: 75.5588 → 8 points

Subject 5: 59.75 → 6 points

GPA = (9*1 + 8*1 + 0*1 + 6*2 + 8*2 + 6*3 ) / (1+1+1+2+2+3) = 6.30

Since he got 0 points in at least one of the subjects he has FAILED

The output format is “RESULT,<space>gpa” without double quotes.


Added by:cegprakash
Date:2011-03-06
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All

hide comments
2019-12-26 10:23:52
getting WA again and again...
plz provide more testcases
2018-06-23 15:54:19
When 100th is such a long One :3
2016-12-13 11:39:33
SPOILER ALERT::Easy problem(basic implementation) but requires lot of labour....
2016-02-20 19:50:01 rahul_verma
When i'm submitting my solution it's showing Internal Error !!!!plz helppp ::
2015-06-02 20:08:18 Avinab saha
can someone give me the test case format with 2 students please!!!
2015-05-29 20:16:41 ASHUTOSH DWIVEDI
fun solving it.....
2015-05-11 20:53:38 Vaporeon
MInd the space after PASSED/FAILED!! ;p
2015-04-21 16:04:05 Suresh Prasanna
Are the inputs for subsequent subjects separated by an empty line ??
2012-09-02 12:40:54 cegprakash
attendance not taken during exam days :P
2012-09-02 12:40:54 cegprakash
INPUT:

1 1 1 1 1 1
20 20 20 100 0
20 20 ab 100 0
ab 20 20 98 0
20 20 20 99.99 10.10
20 20 ab 99 4.5
20 20 20 100 0

OUTPUT:

PASSED, 10.00
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.