GFSSOC '17 J4 - Top Courses

View as PDF

Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 128M

Authors:
Problem types

The Waterloo admission office was DDOSed, which meant that Ace's marks couldn't be processed! Waterloo has sent Ace a form where he must fill in his marks onto. However, it isn't as simple as one would like. Ace has completed N (1 \le N \le 1\,000\,000) grade 12 courses (some aren't as legitimate as others…) with a unique course name, whose length will be no longer than 100 characters, and a grade (0 \le grade \le 100). Waterloo Software Engineering requires that applicants submit C courses and has M mandatory courses that Ace must include (1 \le M \le C \le 1\,000\,000). If Ace does not have enough courses to submit or does not have the mandatory courses, he will fail. Given Ace's grades, calculate the maximum entry average he can submit on his form. If he fails, output Ace is dunzos.

Input Specification

First line: three integers N, C, M.

Next N lines: a string with or without spaces representing the course name, and an integer grade.

Next M lines: a string with or without spaces representing the name of a mandatory course.

Output Specification

Ace's maximum possible average, rounded to 2 decimal places.

Sample Input 1

10 6 5
Chemistry 97
AdvFunc 96
CalcAndVectors 97
Physics 96
CurrentEcon 96
French 96
English 92
Literature 93
Science 98
Philosophy 87
Chemistry
Physics
AdvFunc
English
CalcAndVectors

Sample Output 1

96.00

Comments


  • 0
    LemonTree  commented on Sept. 26, 2024, 1:21 a.m.

    What is a Maximum possible average?


  • 0
    Awabo  commented on April 23, 2024, 12:09 a.m.

    test case #10 TLE, can someone help me


  • 0
    674445  commented on Jan. 18, 2022, 11:10 p.m. edited

    How come first 3 cases give you ValueError in Python 3.9?

    Can the course grade not be a type that cannot be converted to an int?


    • 0
      stick  commented on Jan. 19, 2022, 4:00 p.m. edited

      Consider that course names may contain spaces.