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

31666번 - Precarious Stacks 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB40201544.118%

문제

It’s been difficult finding a job in the tech industry lately. You managed to land a job working for a construction company, but some of the tasks being assigned to you have you wondering whether the engineers have ever heard of gravity. Anyway, in the latest task, you are asked to evaluate the following model of a construction project.

The model is built by dropping axis-aligned squares, each with a specific $x$ coordinate and size, towards the ground (which is defined by the line $y=0$). Each square will move downwards until its bottom face hits the ground or some other square. Once a square lands, it is securely fastened in place, so even if two squares are off balance, they will not fall over.

Given the list of squares to place and the order to place them in, determine the maximum $y$ coordinate reached by the structure after each square is placed.

입력

The first line of input contains an integer $N$ (1ドル \le N \le 10^5$) indicating how many squares there are in the model. The next $N$ lines describe the squares in the ordered they are to be dropped. Line $i$ contains two integers $x_ i$ (0ドル \le x_ i \le 10^9$) and $s_ i$ (1ドル \le s_ i \le 10^9$), indicating the $x$ coordinate of the leftmost edge of square $i$ and the size of square $i,ドル respectively.

출력

Output $N$ lines, with line $i$ containing the $y$ coordinate of the highest point that is reached by the structure after squares 1,ドル\dots ,i$ have been dropped.

제한

예제 입력 1

3
0 1
0 2
0 3

예제 출력 1

1
3
6

예제 입력 2

5
0 1
0 10
9 1
0 10
9 10

예제 출력 2

1
11
12
22
32

예제 입력 3

3
0 1
1 1
2 1

예제 출력 3

1
1
1

예제 입력 4

7
0 5
1 4
2 3
3 2
4 1
0 2
0 5

예제 출력 4

5
9
12
14
15
15
20

힌트

출처

University > University of Alberta Programming Contest > UAPC 2023 > Division 1 I번

  • 문제를 만든 사람: Noah Weninger
(追記) (追記ここまで)

출처

대학교 대회

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

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