Excellent Grades

시간 제한1초메모리 제한2048 MB

요약
이전 성적과 가중치, 기말고사 가중치가 주어질 때 가중 평균을 8.0 이상으로 만드는 최소 기말 성적을 구한다.
난이도

쉬움10점 중 2점

유형
수학, 구현
정답자
아직 제출이 없습니다

문제

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 w_uw\_u (1≤w_u≤30)(1 \leq w\_u \leq 30), the weight of the final exam
  • A line with 1 integer nn (1≤n≤100)(1 \leq n \leq 100), the number of other grades
  • nn lines with 1 double (1 decimal) g_ig\_i (1≤g_i≤10)(1 \leq g\_i \leq 10) and 1 integer w_iw\_i (1≤w_i≤30)(1\leq w\_i \leq 30) where gg is the grade of exam ii and w_iw\_i is the weight of exam ii.

출력

If Eddie can achieve cum laude, print the grade gg (1≤g≤10)(1 \leq g \leq 10) he has to achieve on his final exam, rounded to 1 decimal. Otherwise print IMPOSSIBLE.

예제2

  1. 예제 1

    입력
    3
    3
    8.0 2
    7.0 1
    7.0 4
    
    예상 출력
    9.7
    
  2. 예제 2

    입력
    2
    4
    8.0 2
    6.1 1
    8.3 1
    7.1 3
    
    예상 출력
    IMPOSSIBLE