CF975C.Valhalla Siege

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle.

Ivar has nn warriors, he places them on a straight line in front of the main gate, in a way that the ii-th warrior stands right after (i−1)(i-1)-th warrior. The first warrior leads the attack.

Each attacker can take up to aia_i arrows before he falls to the ground, where aia_i is the ii-th warrior's strength.

Lagertha orders her warriors to shoot kik_i arrows during the ii-th minute, the arrows one by one hit the first still standing warrior. After all Ivar's warriors fall and all the currently flying arrows fly by, Thor smashes his hammer and all Ivar's warriors get their previous strengths back and stand up to fight again. In other words, if all warriors die in minute tt, they will all be standing to fight at the end of minute tt.

The battle will last for qq minutes, after each minute you should tell Ivar what is the number of his standing warriors.

无骨者伊瓦尔是一位伟大的领袖。他正试图从拉格莎手中夺取卡特加特。战争已经打响,伊瓦尔的战士们一波又一波地在战斗中倒下。

伊瓦尔有 nn 名战士,他将他们排成一条直线,列于主城门前,其中第 ii 名战士恰好站在第 (i−1)(i-1) 名战士之后。第一名战士率先发起进攻。

每名进攻者最多可承受 aia_i 支箭矢后才会倒地,其中 aia_i 表示第 ii 名战士的体力值。

拉格莎命令她的战士们在第 ii 分钟射出 kik_i 支箭;这些箭一支接一支地命中当前仍站立着的、位置最靠前的那名战士。当伊瓦尔的所有战士全部倒地,且所有正在飞行中的箭矢均已飞过之后,雷神索尔会挥动他的锤子,使伊瓦尔的所有战士立即恢复原有体力并重新站起来继续战斗。换言之,若所有战士均在第 tt 分钟倒下,则他们将在第 tt 分钟结束时全部重新站立起来投入战斗。

整场战斗将持续 qq 分钟;在每一分钟结束后,你需要告诉伊瓦尔:此时他还有多少名战士仍然站立着。

输入格式

The first line contains two integers nn and qq (1≤n,q≤200 0001 \le n, q \leq 200\,000) — the number of warriors and the number of minutes in the battle.

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \leq a_i \leq 10^9) that represent the warriors' strengths.

The third line contains qq integers k1,k2,…,kqk_1, k_2, \ldots, k_q (1≤ki≤10141 \leq k_i \leq 10^{14}), the ii-th of them represents Lagertha's order at the ii-th minute: kik_i arrows will attack the warriors.

第一行包含两个整数 nn 和 qq(1≤n,q≤200 0001 \le n, q \leq 200\,000),分别表示战士的数量和战斗持续的分钟数。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \leq a_i \leq 10^9),表示各位战士的战斗力。

第三行包含 qq 个整数 k1,k2,…,kqk_1, k_2, \ldots, k_q(1≤ki≤10141 \leq k_i \leq 10^{14}),其中第 ii 个数表示拉格莎在第 ii 分钟下达的命令:将有 kik_i 支箭攻击战士。

输出格式

Output qq lines, the ii-th of them is the number of standing warriors after the ii-th minute.

输出 qq 行,其中第 ii 行表示第 ii 分钟后仍然站立的战士数量。

输入输出样例

  • 输入#1

    5 5
    1 2 1 2 1
    3 10 1 1 1

    输出#1

    3
    5
    4
    4
    3
  • 输入#2

    4 4
    1 2 3 4
    9 1 10 6

    输出#2

    1
    4
    4
    1

说明/提示

In the first example:

  • after the 1-st minute, the 1-st and 2-nd warriors die.
  • after the 2-nd minute all warriors die (and all arrows left over are wasted), then they will be revived thus answer is 5 — all warriors are alive.
  • after the 3-rd minute, the 1-st warrior dies.
  • after the 4-th minute, the 2-nd warrior takes a hit and his strength decreases by 1.
  • after the 5-th minute, the 2-nd warrior dies.

在第一个例子中:

  • 第 1 分钟后,第 1 和第 2 名战士死亡。
  • 第 2 分钟后,所有战士均死亡(剩余的所有箭矢均被浪费),随后他们将被复活,因此答案为 5 —— 所有战士均存活。
  • 第 3 分钟后,第 1 名战士死亡。
  • 第 4 分钟后,第 2 名战士受到一次攻击,其生命值减少 1。
  • 第 5 分钟后,第 2 名战士死亡。

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

首页