#QHD0000025. Chiến lược học thi (Term Strategy)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Chiến lược học thi (Term Strategy)
Term Strategy
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
A student is preparing for exams in subjects and has at most hours to study.
For subject , spending exactly hours gives grade on a scale of through . Each subject must receive at least one hour and a passing grade of at least . The total hours allocated must not exceed .
If passing all subjects is possible, determine the highest possible average grade; otherwise print the specified failure message.
Input
The first line contains and .
Each of the following lines contains integers : the grade for subject when studying exactly hours.
Output
If passing all subjects is impossible, print Peter, you shouldn't have played billiard that much..
Otherwise print Maximal possible average mark - X. where X is the highest average formatted to exactly two decimal places.
Subtasks
- Subtask 1 (20 points): ; ; ; are nondecreasing with ; each subject is allotted at least one hour.
- Subtask 2 (30 points): ; ; ; are nondecreasing with ; each subject is allotted at least one hour.
- Subtask 3 (50 points): ; ; ; are nondecreasing with ; each subject is allotted at least one hour.
Examples
Input
4 5
5 5 6 7 8
5 5 6 7 8
5 6 7 8 8
6 7 8 9 9
Output
Maximal possible average mark - 5.50.
Explanation
Each of the four subjects requires at least one hour, leaving only one extra hour. Allocating hours earns grades for a total of and an average of . No feasible allocation scores higher, so the stated message is printed.