CF609F.Frogs and mosquitoes

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

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.

有 nn 只青蛙坐在坐标轴 OxOx 上。对第 ii 只青蛙,已知两个值 xix_i 和 tit_i —— 分别表示该青蛙的位置及其舌头的初始长度(保证所有位置 xix_i 互不相同)。依次有 mm 只蚊子降落在坐标轴上。对第 jj 只蚊子,已知两个值:pjp_j —— 该蚊子降落的位置坐标,以及 bjb_j —— 该蚊子的尺寸。青蛙和蚊子均被表示为坐标轴上的点。

一只青蛙可以吃掉一只蚊子,当且仅当该蚊子位于该青蛙所在位置或其右侧,且两者之间的距离不超过该青蛙舌头的长度。

在某一时刻,若有多只青蛙都能吃掉同一只蚊子,则最左侧的青蛙(即 xix_i 最小者)将吃掉它。青蛙吃掉蚊子后,其舌头长度增加量等于所吃蚊子的尺寸 bjb_j。有可能在舌头变长之后,该青蛙又能吃掉其他尚未被吃掉的蚊子(此时该青蛙必须立即吃掉所有它能吃掉的新蚊子)。

对每只青蛙,请输出两个值:它总共吃掉的蚊子数量,以及在所有蚊子全部降落完毕、且所有青蛙吃完所有可能的蚊子之后,它的舌头长度。

每只蚊子仅在之前所有已降落的蚊子均已被青蛙尽可能吃掉之后,才降落到坐标轴上。输入中蚊子按其降落顺序给出。

输入格式

First line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the number of frogs and mosquitoes.

Each of the next n lines contains two integers x__i, t__i (0 ≤ x__i, t__i ≤ 109) — 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 ≤ 109) — the position and the size of the j-th mosquito.

第一行包含两个整数 nn 和 mm(1≤n,m≤2⋅1051 \leq n, m \leq 2 \cdot 10^5)—— 分别表示青蛙的数量和蚊子的数量。

接下来的 nn 行,每行包含两个整数 xix_i、tit_i(0≤xi,ti≤1090 \leq x_i, t_i \leq 10^9)—— 表示第 ii 只青蛙的位置及其舌头的初始长度。保证所有 xix_i 互不相同。

接下来的 mm 行,每行包含两个整数 pjp_j、bjb_j(0≤pj,bj≤1090 \leq p_j, b_j \leq 10^9)—— 表示第 jj 只蚊子的位置及其大小。

输出格式

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.

输出 n 行。第 i 行应包含两个整数值 c__i 和 l__i —— 分别表示第 i 只青蛙吃掉的蚊子数量以及第 i 只青蛙的舌头长度。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页