Universal Cup Judging System

Universal Cup

Límite de tiempo: 2.0 s Límite de memoria: 512 MB Puntuación total: 100 Hackeable ✓
Estadísticas

題目描述

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