CF56E.Domino Principle

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya is interested in arranging dominoes. He is fed up with common dominoes and he uses the dominoes of different heights. He put nn dominoes on the table along one axis, going from left to right. Every domino stands perpendicular to that axis so that the axis passes through the center of its base. The ii -th domino has the coordinate xix_{i} and the height hih_{i} . Now Vasya wants to learn for every domino, how many dominoes will fall if he pushes it to the right. Help him do that.

Consider that a domino falls if it is touched strictly above the base. In other words, the fall of the domino with the initial coordinate xx and height hh leads to the fall of all dominoes on the segment [x+1,x+h1][x+1,x+h-1] .

输入格式

The first line contains integer nn ( 1<=n<=1051<=n<=10^{5} ) which is the number of dominoes. Then follow nn lines containing two integers xix_{i} and hih_{i} ( 108<=xi<=108,2<=hi<=108-10^{8}<=x_{i}<=10^{8},2<=h_{i}<=10^{8} ) each, which are the coordinate and height of every domino. No two dominoes stand on one point.

输出格式

Print nn space-separated numbers ziz_{i} — the number of dominoes that will fall if Vasya pushes the ii -th domino to the right (including the domino itself).

输入输出样例

  • 输入#1

    4
    16 5
    20 5
    10 10
    18 2
    

    输出#1

    3 1 4 1 
  • 输入#2

    4
    0 10
    1 5
    9 10
    15 10
    

    输出#2

    4 1 2 1 
首页