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

18390번 - COPSCH 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB872100.000%

문제

Senobar is a student and works in copy shop center of university at noon. The copy shop center of university receives many orders from professors and students.

Every day she receives orders for tomorrow and registers the reception time, the amount of order in 1000 pages unit and the determined deadline by the customers for each order. Then, she will do them tomorrow from 12:00.

She really likes do the best for her customers but sometimes the amount of orders is over than the capacity of copy shop’s machine. Therefore, she cannot satisfy determined deadline by her customers always and concerned about the best schedule for doing the orders so that, the maximum amount by which an order’s completion time overshoots its deadline is minimized. Help her to schedule the orders. Note that the capacity of the machine’s page container is 1000 pages, which copy them in 1 hour. Moreover, she does not have to do an order at a stretch. She may do a unit of order A (1000 pages), then do some units of other orders and after that comes back to the order A.

입력

The first line contains the number of orders, T .Each of the next T lines contains two integers, D and U that illustrate: the deadline of each order (in pm), and the number of pages (in unit: 1000 pages) respectively.

출력

Output should be in T lines, which contain the value of the maximum amount by which an order's completion time overshoots its deadline, when the first i orders on your list are scheduled optimally. See the sample input for clarification.

제한

  • 1 ≤ T ≤ 105
  • 1 ≤ Ui ≤ 103

예제 입력 1

5
2 2
1 1
4 3
10 1
2 1

예제 출력 1

0
1
2
2
3

힌트

The first order alone can be completed in 2 hour, and so you won't overshoot the deadline.

With the first two orders, the optimal schedule can be:

  • time 1: order 2
  • time 2: order 1
  • time 3: order 1

We've overshot order 1 by 1 hour, hence returning 1.

With the first three orders, the optimal schedule can be:

  • time 1: order 2
  • time 2: order 1
  • time 3: order 3
  • time 4: order 1
  • time 5: order 3
  • time 6: order 3

Order 1 has a deadline 2, and it finishes at time 4. So, it exceeds its deadline by 2. Order 2 has a deadline 1, and it finishes at time 1. So, it exceeds its deadline by 0. Order 3 has a deadline 4, and it finishes at time 6. So, it exceeds its deadline by 2.

Thus, the maximum time by which you overshoot a deadline is 2. No schedule can do better than this. Similar calculation can be done for the case containing 5 orders.

출처

ICPC > Regionals > Asia West Continent > Afghanistan > Asia-Kabul ICPC Regional Contest 2018 I번

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

출처

대학교 대회

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

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