A8012 | Domino Principle
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vasya is interested in arranging dominoes. He is fed up with common dominoes and he uses the dominoes of different heights. He put $n$ 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 $i$ -th domino has the coordinate $x_{i}$ and the height $h_{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 $x$ and height $h$ leads to the fall of all dominoes on the segment $[x+1,x+h-1]$ .

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 $x$ and height $h$ leads to the fall of all dominoes on the segment $[x+1,x+h-1]$ .

输入格式
The first line contains integer $n$ ( $1<=n<=10^{5}$ ) which is the number of dominoes. Then follow $n$ lines containing two integers $x_{i}$ and $h_{i}$ ( $-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 $n$ space-separated numbers $z_{i}$ — the number of dominoes that will fall if Vasya pushes the $i$ -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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted