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 มีการ์ด Snakebite ทั้งหมด $n$ ใบ ผลของใบที่ $i$ คือ: เมื่อเล่นการ์ดใบนี้ จะเพิ่มจำนวนชั้นพิษของศัตรูขึ้น $v_i$ โดย Yuki จะเล่นการ์ด Snakebite ใบที่ $i$ เมื่อเริ่มต้นเทิร์นที่ $t_i$

เมื่อสิ้นสุดแต่ละเทิร์น ให้ $x$ เป็นจำนวนชั้นพิษบนตัวศัตรู:

  • หาก $x = 0$ จะไม่มีอะไรเกิดขึ้น
  • หาก $x \neq 0$ ศัตรูจะได้รับความเสียหาย $x$ หน่วย และจำนวนชั้นพิษจะลดลง $1$ กล่าวคือ $x \leftarrow x - 1$

เพื่อทำให้ความเสียหายรวมที่ทำต่อศัตรูมากที่สุด Yuki สามารถทำการเสริมพลัง (enchantment) ได้ $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.