Universal Cup Judging System

Universal Cup

時間限制: 2.0 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓
统计

問題文

「Snakebite(ヘビ咬み)」はゲーム Slay the Spire 2 で最も強力なカードであり、Yuki はこれを使って敵を倒すのが大好きです。

ゲームは $10^{1000}$ ターン続きます。ゲーム開始時、敵の毒の層数は $0$ です。

Yuki は合計 $n$ 枚の Snakebite カードを持っています。$i$ 番目の Snakebite の効果は、プレイしたときに敵の毒の層数を $v_i$ 増やすというものです。Yuki は $t_i$ ターン目の開始時に $i$ 番目の Snakebite をプレイします。

各ターンの終了時、敵に付与されている毒の層数を $x$ とすると:

  • $x = 0$ の場合、何も起こりません。
  • $x \neq 0$ の場合、敵は $x$ のダメージを受け、毒の層数が $1$ 減少します(すなわち $x \leftarrow x - 1$)。

敵に与える総ダメージを最大化するために、Yuki はゲームが始まる前に $k$ 回のエンチャント(強化)を行うことができます。各エンチャントでは、Yuki は正の整数 $i \le n$ を選び、$v_i$ の値を $1$ 増やします。同じ添字 $i$ を複数回選ぶことも可能です。

Yuki が $k$ 回のエンチャントを行った後に敵が受けることができる最大ダメージを求めてください。

入力

各テストには複数のテストケースが含まれます。1 行目にはテストケースの数を表す整数 $t$($1 \le t \le 10^4$)が与えられます。

各テストケースについて:

  • 1 行目には 2 つの整数 $n, k$($1 \le n \le 3 \cdot 10^5$、$0 \le k \le 10^9$)が与えられます。
  • 2 行目には $n$ 個の整数 $v_1, v_2, \dots, v_n$($1 \le v_i \le 10^9$、$1 \le \sum v_i \le 10^9$)が与えられます。
  • 3 行目には $n$ 個の整数 $t_1, t_2, \dots, t_n$($1 \le t_i \le 10^9$)が与えられます。

すべてのテストケースにおける $n$ の総和は $3 \cdot 10^5$ を超えないことが保証されます。

出力

各テストケースについて、Yuki が $k$ 回のエンチャントを行った後に敵が受けることができる最大ダメージを表す整数を 1 行に出力してください。

入力例・出力例

入力例 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.