CF1922D.Berserk Monsters

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Monocarp is playing a computer game (yet again). Guess what is he doing? That's right, killing monsters.

There are nn monsters in a row, numbered from 11 to nn. The ii-th monster has two parameters: attack value equal to aia_i and defense value equal to did_i. In order to kill these monsters, Monocarp put a berserk spell on them, so they're attacking each other instead of Monocarp's character.

The fight consists of nn rounds. Every round, the following happens:

  • first, every alive monster ii deals aia_i damage to the closest alive monster to the left (if it exists) and the closest alive monster to the right (if it exists);
  • then, every alive monster jj which received more than djd_j damage during this round dies. I. e. the jj-th monster dies if and only if its defense value djd_j is strictly less than the total damage it received this round.

For each round, calculate the number of monsters that will die during that round.

Monocarp 正在玩一款电脑游戏(又一次)。猜猜他在干什么?没错,就是在打怪。

一共有 nn 只怪物排成一列,编号从 11 到 nn。第 ii 只怪物有两个参数:攻击力为 aia_i,防御力为 did_i。为了消灭这些怪物,Monocarp 对它们施加了一个狂暴咒语,因此它们转而互相攻击,而非攻击 Monocarp 的角色。

战斗共进行 nn 轮。每轮中,发生以下事件:

  • 首先,每个尚存的怪物 ii 向其左侧最近的尚存怪物(若存在)和右侧最近的尚存怪物(若存在)各造成 aia_i 点伤害;
  • 然后,所有在本轮中受到的总伤害严格大于其防御力 djd_j 的尚存怪物 jj 将死亡。即:第 jj 只怪物死亡当且仅当其防御力 djd_j 严格小于它在本轮中受到的总伤害。

对每一轮,请计算该轮中死亡的怪物数量。

输入格式

The first line contains one integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

Each test case consists of three lines:

  • the first line contains one integer nn (1≤n≤3⋅1051 \le n \le 3 \cdot 10^5);
  • the second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤1091 \le a_i \le 10^9);
  • the third line contains nn integers d1,d2,…,dnd_1, d_2, \dots, d_n (1≤di≤1091 \le d_i \le 10^9).

Additional constraint on the input: the sum of nn over all test cases does not exceed 3⋅1053 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 表示测试用例的数量。

每个测试用例由三行组成:

  • 第一行包含一个整数 nn(1≤n≤3⋅1051 \le n \le 3 \cdot 10^5);
  • 第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤1091 \le a_i \le 10^9);
  • 第三行包含 nn 个整数 d1,d2,…,dnd_1, d_2, \dots, d_n(1≤di≤1091 \le d_i \le 10^9)。

输入的附加约束:所有测试用例的 nn 值之和不超过 3⋅1053 \cdot 10^5。

输出格式

For each test case, print nn integers. The ii-th integer should be equal to the number of monsters that die during the ii-th round.

对于每个测试用例,输出 nn 个整数。其中第 ii 个整数应等于在第 ii 轮中死亡的怪物数量。

输入输出样例

  • 输入#1

    3
    5
    3 4 7 5 10
    4 9 1 18 1
    2
    2 1
    1 3
    4
    1 1 2 4
    3 3 4 2

    输出#1

    3 1 0 0 0 
    0 0 
    1 1 1 0

说明/提示

Explanation for the first test case of the example:

During the first round, the following happens:

  • the monster 11 deals 33 damage to the monster 22;
  • the monster 22 deals 44 damage to the monster 11 and the monster 33;
  • the monster 33 deals 77 damage to the monster 22 and the monster 44;
  • the monster 44 deals 55 damage to the monster 33 and the monster 55;
  • the monster 55 deals 1010 damage to the monster 44;
  • the monster 11 does not die, since it received 44 damage and its defense is 44;
  • the monster 22 dies, since it received 1010 damage and its defense is 99;
  • the monster 33 dies, since it received 99 damage and its defense is 11;
  • the monster 44 does not die, since it received 1717 damage and its defense is 1818;
  • the monster 55 dies, since it received 55 damage and its defense is 11.

After the first round, the monsters 11 and 44 stay alive.

During the second round, the following happens:

  • the monster 11 deals 33 damage to the monster 44;
  • the monster 44 deals 55 damage to the monster 11;
  • the monster 11 dies, since it received 55 damage and its defense is 44;
  • the monster 44 does not die, since it received 33 damage and its defense is 1818.

During the next three rounds, only the 44-th monster is alive, so nothing happens.

示例中第一个测试用例的解释:

在第一轮中,发生以下情况:

  • 怪物 11 对怪物 22 造成 33 点伤害;
  • 怪物 22 对怪物 11 和怪物 33 各造成 44 点伤害;
  • 怪物 33 对怪物 22 和怪物 44 各造成 77 点伤害;
  • 怪物 44 对怪物 33 和怪物 55 各造成 55 点伤害;
  • 怪物 55 对怪物 44 造成 1010 点伤害;
  • 怪物 11 未死亡,因为它受到了 44 点伤害,而其防御力为 44;
  • 怪物 22 死亡,因为它受到了 1010 点伤害,而其防御力为 99;
  • 怪物 33 死亡,因为它受到了 99 点伤害,而其防御力为 11;
  • 怪物 44 未死亡,因为它受到了 1717 点伤害,而其防御力为 1818;
  • 怪物 55 死亡,因为它受到了 55 点伤害,而其防御力为 11。

第一轮结束后,仅怪物 11 和怪物 44 存活。

在第二轮中,发生以下情况:

  • 怪物 11 对怪物 44 造成 33 点伤害;
  • 怪物 44 对怪物 11 造成 55 点伤害;
  • 怪物 11 死亡,因为它受到了 55 点伤害,而其防御力为 44;
  • 怪物 44 未死亡,因为它受到了 33 点伤害,而其防御力为 1818。

在接下来的三轮中,仅有第 44 号怪物存活,因此不发生任何事件。

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

首页