Universal Cup Judging System

Universal Cup

Time Limit: 2.0 s Memory Limit: 512 MB Total points: 100 Hackable ✓
Statistics

題目描述

「蛇咬」(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.