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

18819번 - Jumping Junipers 다국어

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

문제

Jack and Jill have a house in the woods. They have planted some juniper trees in a straight line that goes straight away from their house. Each tree is planted an integer distance from their house along this line. No two trees are at the same location.

Jack and Jill would like to move the trees closer to their home. Since the trees are heavy, they can only move the trees a certain distance in either direction (the distance for each tree can be different). The trees must end up at positive integer distances from their house along the line and no two trees may end up at the same place. Jack and Jill would like to minimize the sum of distances of the trees from their house. Show them how to do this.

입력

The first line contains a single integer n (1 ≤ n ≤ 200 000), which is the number of trees.

The next n lines describe the trees. Each of these lines contains two integers d (1 ≤ d ≤ 109), which is the distance of this tree from their house, and t (0 ≤ t ≤ 109), which is the maximum distance that this tree can be moved in either direction.

출력

Display the new locations of the n trees (in the same order as given in input) that minimizes the sum of distances from Jack and Jill’s house.

If there are multiple solutions, any one will be accepted.

제한

예제 입력 1

3
12 3
11 1
100 1

예제 출력 1

9 10 99

예제 입력 2

2
10 2
12 4

예제 출력 2

8 9

예제 입력 3

2
343 117
100 15

예제 출력 3

226 85

힌트

출처

ICPC > Regionals > South Pacific > South Pacific Region > 2019 ICPC South Pacific Regionals J번

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

출처

대학교 대회

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

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