Excellent Grades
시간 제한1초메모리 제한2048 MB
이전 성적과 가중치, 기말고사 가중치가 주어질 때 가중 평균을 8.0 이상으로 만드는 최소 기말 성적을 구한다.
문제
In order to receive his propedeutic degree cum laude, the weighted average of all of Eddie's grades must be at least 8.0. Of course he must also have passed all of his courses, which requires a grade of at least 5.8. With only one exam to go, Eddie is wondering if he still has a shot at achieving cum laude.
Given all of the grades for Eddie's previous courses and their weights, and the weight of the final exam, check if Eddie can still obtain his degree cum laude. If he can, output the grade Eddie requires for his final exam to achieve this. Otherwise output IMPOSSIBLE.
입력
- A line with 1 integer , the weight of the final exam
- A line with 1 integer , the number of other grades
- lines with 1 double (1 decimal) and 1 integer where is the grade of exam and is the weight of exam .
출력
If Eddie can achieve cum laude, print the grade he has to achieve on his final exam, rounded to 1 decimal. Otherwise print IMPOSSIBLE.