Universal Cup Judging System

Universal Cup

시간 제한: 2.0 s 메모리 제한: 512 MB 총점: 100 해킹 가능 ✓
통계

题目描述

“蛇咬”(Snakebite)是游戏 Slay the Spire 2 中最强大的卡牌,Yuki 喜欢用它来击败敌人。

游戏持续 $10^{1000}$ 个回合。游戏开始时,敌人身上有 $0$ 层中毒。

Yuki 一共有 $n$ 张蛇咬牌。第 $i$ 张蛇咬牌的效果是:打出时,使敌人的中毒层数增加 $v_i$。Yuki 会在第 $t_i$ 个回合开始时打出第 $i$ 张蛇咬牌。

在每个回合结束时,设敌人身上的中毒层数为 $x$:

  • 如果 $x = 0$,什么也不会发生;
  • 如果 $x \neq 0$,敌人受到 $x$ 点伤害,且中毒层数减少 $1$,即 $x \leftarrow x - 1$。

为了最大化对敌人造成的总伤害,Yuki 可以在游戏开始前进行 $k$ 次附魔。在每次附魔中,Yuki 选择一个正整数 $i \le n$ 并将 $v_i$ 的值增加 $1$。同一个下标 $i$ 可以被选择多次。

你需要求出在 Yuki 进行 $k$ 次附魔后,敌人最多能受到多少伤害。

输入格式

每个测试点包含多组测试数据。第一行包含一个整数 $t$($1 \le t \le 10^4$),表示测试数据的组数。

对于每组测试数据:

  • 第一行包含两个整数 $n, k$($1 \le n \le 3 \cdot 10^5$,$0 \le k \le 10^9$)。
  • 第二行包含 $n$ 个整数 $v_1, v_2, \dots, v_n$($1 \le v_i \le 10^9$,$1 \le \sum v_i \le 10^9$)。
  • 第三行包含 $n$ 个整数 $t_1, t_2, \dots, t_n$($1 \le t_i \le 10^9$)。

保证所有测试数据中 $n$ 的总和不超过 $3 \cdot 10^5$。

输出格式

对于每组测试数据,输出一行一个整数,表示在 Yuki 进行 $k$ 次附魔后敌人能受到的最大伤害。

样例

样例输入 1

5
2 1
2 3
1 4
2 2
3 4
1 3
4 1
3 3 1 4
4 4 1 5
3 0
16 27 62
9 88 11
3 5
9 3 1
8 3 3

样例输出 1

13
37
63
3335
126

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.