Bsil's Admission Strategy
InterviewTime limit1sMemory limit1024 MB
Given subject scores, find the minimum and maximum total of M subjects that must include the K publicly announced ones.
Problem
Bsil is a senior in high school this year. Bsil wants to get into Bronze-Silver University (Bsil University), the best university in the world, and plans an admission strategy based on current grades. Bsil University decides whether an applicant passes the document screening by the sum of grades in certain subjects. However, the university does not reveal every subject that counts toward the document review. It publishes only some of them, which makes it a wicked school. Given the number of subjects the university requires and the subjects it publicly says count, find the minimum and maximum scores Bsil can get.
The public subjects and the non-public subjects are all among the subjects Bsil took, and no subject is repeated.
Input
The first line contains the number of subjects that Bsil took, the number of subjects that Bsil University requires, and the number of subjects that the university publicly announced, separated by spaces.
The next lines each contain a subject name and an integer score , separated by a space. consists only of lowercase English letters.
The next lines each contain a subject name that the university publicly announced. consists only of lowercase English letters.
Output
Print the minimum and maximum scores Bsil can get, separated by a space.