A10089 | Frogs and mosquitoes
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There are $n$ frogs sitting on the coordinate axis $Ox$ . For each frog two values $x_{i},t_{i}$ are known — the position and the initial length of the tongue of the $i$ -th frog (it is guaranteed that all positions $x_{i}$ are different). $m$ mosquitoes one by one are landing to the coordinate axis. For each mosquito two values are known $p_{j}$ — the coordinate of the position where the $j$ -th mosquito lands and $b_{j}$ — the size of the $j$ -th mosquito. Frogs and mosquitoes are represented as points on the coordinate axis.
The frog can eat mosquito if mosquito is in the same position with the frog or to the right, and the distance between them is not greater than the length of the tongue of the frog.
If at some moment several frogs can eat a mosquito the leftmost frog will eat it (with minimal $x_{i}$ ). After eating a mosquito the length of the tongue of a frog increases with the value of the size of eaten mosquito. It's possible that after it the frog will be able to eat some other mosquitoes (the frog should eat them in this case).
For each frog print two values — the number of eaten mosquitoes and the length of the tongue after landing all mosquitoes and after eating all possible mosquitoes by frogs.
Each mosquito is landing to the coordinate axis only after frogs eat all possible mosquitoes landed before. Mosquitoes are given in order of their landing to the coordinate axis.
The frog can eat mosquito if mosquito is in the same position with the frog or to the right, and the distance between them is not greater than the length of the tongue of the frog.
If at some moment several frogs can eat a mosquito the leftmost frog will eat it (with minimal $x_{i}$ ). After eating a mosquito the length of the tongue of a frog increases with the value of the size of eaten mosquito. It's possible that after it the frog will be able to eat some other mosquitoes (the frog should eat them in this case).
For each frog print two values — the number of eaten mosquitoes and the length of the tongue after landing all mosquitoes and after eating all possible mosquitoes by frogs.
Each mosquito is landing to the coordinate axis only after frogs eat all possible mosquitoes landed before. Mosquitoes are given in order of their landing to the coordinate axis.
输入格式
First line contains two integers $n,m$ ( $1<=n,m<=2·10^{5}$ ) — the number of frogs and mosquitoes.
Each of the next $n$ lines contains two integers $x_{i},t_{i}$ ( $0<=x_{i},t_{i}<=10^{9}$ ) — the position and the initial length of the tongue of the $i$ -th frog. It is guaranteed that all $x_{i}$ are different.
Next $m$ lines contain two integers each $p_{j},b_{j}$ ( $0<=p_{j},b_{j}<=10^{9}$ ) — the position and the size of the $j$ -th mosquito.
Each of the next $n$ lines contains two integers $x_{i},t_{i}$ ( $0<=x_{i},t_{i}<=10^{9}$ ) — the position and the initial length of the tongue of the $i$ -th frog. It is guaranteed that all $x_{i}$ are different.
Next $m$ lines contain two integers each $p_{j},b_{j}$ ( $0<=p_{j},b_{j}<=10^{9}$ ) — the position and the size of the $j$ -th mosquito.
输出格式
Print $n$ lines. The $i$ -th line should contain two integer values $c_{i},l_{i}$ — the number of mosquitoes eaten by the $i$ -th frog and the length of the tongue of the $i$ -th frog.
输入输出样例
输入 #1
4 6 10 2 15 0 6 1 0 1 110 10 1 1 6 0 15 10 14 100 12 2
输出 #1
3 114 1 10 1 1 1 2
输入 #2
1 2 10 2 20 2 12 1
输出 #2
1 3
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted