Alan
has recently joined an Engineering college. On the first day he came to know
that each semester will contain N number of subjects and Di (where
1<=i<=N) is the credit associated with that particular subject. In order
to be eligible for the next semester each student must get at least X number of
credits from the current semester. After knowing this Alan became tensed and
nervous, but after discussing with seniors he came to know that getting X
number of credits from N number of subjects is easy if they concentrate on
particular subjects rather than all subjects. But Alan is having preference
list of subjects. As compared with others Alan will give more preference to the
subjects listed in preference list.
Based on past results Alan expects pass percentage Pi (where i<=i<=N) for
each subject. Now Alan needs to get X number of credits in the current
semester. Can you please help the Alan to select the subjects on which he needs
to concentrate on, to get exactly X number of credits.
Input
Format:
First
line of input contains a single integer N, number of subjects present in a
current semester, next N lines follows each line contains Si, Di, Pi where Si
is the name of the subject, Di is the credit associated with the particular
subject, Pi is the pass percentage of the subject. After N lines next line
contains X, number of credits needed and the final line will contain the Alan's
preference list (N subjects, separated by a space).
|
Line 1 |
|
|
Line 2 |
|
|
… |
Si Di Pi |
|
Line N+1 |
|
|
Line N+2 |
|
|
Line N+3 |
|
Constraints:
1<=N<=25,
where N is the number of subjects.
1<=|Di|<=100, where |Di| is the credits associated with the subject
(where 1<=i<=N).
1<=X<=C (C=Sum of Di, where i=1, …, N), where X is the credits needed for
next semester's promotion.
1<=|Si|<=50, where |Si| is the subject name length (where 1<=i<=N).
1<=Pi<=100, where Pi is the pass percentage of the subject (where
1<=i<=N).
Note:
1.
If
there present multiple set of subjects, then print the first set with highest
average pass percentage, and if there are any sets with same average pass
percentage then select the set based on the preference list. Please print the
subject names separated by a space.
2.
There
will be at-least one way to get X number of credits.
Output:
|
Line 1 |
|
Sample
Input and Output
|
SNo. |
Input |
Output |
|
1 |
|
|


0 Comments