|
|||
Grades
Peter is reviewing his midterm grades—something seems off. He needs to improve a few subjects, but time is limited… He has to plan his improvements: which subjects to focus on, what grades to aim for, and how much time to allocate to each. He thinks as follows: “I have subjects, I know my current grades (), and I have time units to prepare. I also know how much time I need to improve in subject from a grade of 1 to 2, from 2 to 3, from 3 to 4, or from 4 to 5 (). Naturally, if I want to improve from 2 to 4 in subject , I need time to prepare. I absolutely don’t want to fail any subjects, so I must improve all grades of 1. Within the given time limit , what is the best average grade I can achieve?” Let’s help him answer this question! Example: N=2 current grades: 1, 2 T=20 the needed preparing times: 1. subject: 8 8 9 10 2. subject: 2 3 4 5 He has two choices: - Improve in the 1. subject to 2, and devote the remaining to the 2. subject This way 8+(3+4+5) time units used, and the average is 3.5. - Improve to 3 in each subjects. This way (8+8)+3 time units used, and the average is 3.0. Input specificationThe first line contains the number of subjects, . The second line lists the current grades, . The third line contains the available time, . The following lines each contain the times required for improvement, The numbers on each line are separated by spaces. Output specification
If it is possible to improve all grades to at least a 2, output the best
achievable average rounded to 2 decimal places on a single line.
Otherwise, output the string Constraints
Sample input 1
Sample output 1
Sample input 2
Sample output 2
Sample input 3
Sample output 3
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |