Logo
(追記) (追記ここまで)

7663번 - Dreadful Deadlines 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB35181145.833%

문제

Contrary to popular belief, diligence does not always pay off! Over the course of his years as an earnest Stanford undergraduate, David found that despite his best efforts, work would always expand to fill the time available. In order to improve his day-to-day efficiency,

David has decided to learn the art of procrastination. David has n assignments due next week. The ith assignment takes xi units of time and must be finished by time ti. David can only work on one assignment at a time, and once David begins an assignment, he must work until it is finished. What is the latest time that David can start in order to ensure that all his deadlines are met?

입력

The input file will contain multiple test cases. Each test case consists of three lines. The first line of each test case contains a single integer n (1 ≤ n ≤ 1000). The second line of each test case contains n integers, x1 x2 ... xn (1 ≤ xi ≤ 10) separated by single spaces. The third line of each test case contains n integers, t1 t2 ... tn (1 ≤ ti ≤ 1000) separated by single spaces.

A blank line separates input test cases, as seen in the sample input below. A single line containing “0” marks the end of input; do not process this case.

출력

For each input test case, print a single line containing an integer indicating the latest time that Jim can start yet still manage to finish all his assignments on time. If the latest time would require Jim to start before time 0, print “impossible”.

제한

예제 입력 1

3
1 2 1
9 9 7
2
2 2
3 3
0

예제 출력 1

5
impossible

힌트

출처

University > Stanford Local ACM Programming Contest > SLPC 2008 D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /