Precarious Stacks
시간 제한4초메모리 제한1024 MB
축에 나란한 정사각형을 차례로 떨어뜨려 땅이나 먼저 놓인 정사각형 위에 얹고, 매번 구조물의 최대 높이를 구한다.
문제
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 coordinate and size, towards the ground (which is defined by the line ). 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 coordinate reached by the structure after each square is placed.
입력
The first line of input contains an integer () indicating how many squares there are in the model. The next lines describe the squares in the ordered they are to be dropped. Line contains two integers () and (), indicating the coordinate of the leftmost edge of square and the size of square , respectively.
출력
Output lines, with line containing the coordinate of the highest point that is reached by the structure after squares have been dropped.