In Ms. Echo's ICS4U class there are 4 components that determine a student's final grade: Tests, Assignments, Projects and Quizzes. She changes the weights on each of these components from year to year. Last year it was tests, assignments, projects and quizzes, but who knows what it will be this year? To pass the course, a student has to get or more on the weighted average of all four components.
For example, last year Rosa got on the tests, on assignments, on projects and on the quizzes. That means her mark is:
Ms. Echo plays hardball – she never passes a student with less than , even if that student got . All the marks are in for this year. How many students will be passing?
The input will contain test cases.
The first line of each test case contains four integers and separated by spaces, representing the weights of the four components and .
This is followed by a line with a single integer representing the number of students in the class (). The next lines each contain four integers and , separated by spaces, representing the marks of an individual student (out of ) for each component and ). Your program should output a single integer for each test case representing the number of students who passed the course that year.
Note that the sample data below contains only test cases but the test data will contain .
Sample Input
72 4 8 16
7
68 89 4 93
79 5 74 49
38 89 62 41
24 96 49 56
73 32 17 55
65 37 64 73
8 99 94 80
4 85 0 11
2
57 84 70 57
81 1 85 31
88 1 3 8
6
60 76 21 84
61 86 1 61
54 49 41 78
6 38 74 83
66 39 68 72
82 16 19 16
92 8 0 0
4
66 3 93 84
14 32 68 17
72 59 43 1
47 53 69 89
Sample Output
4
1
5
2
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments
Not sure if it's a problem with the judge or if its just me, but I had to change my if statement to "if (score>=49.9)" instead of 50, even though I think the question is saying you shouldn't have to do that. Just for reference if anyone is getting an X on the 7th or 8th test of the first case.
The discrepancy is due to precision loss when you divide. Try comparing to 5000 instead of 50.