Universal Cup Judging System

Universal Cup

実行時間制限: 2.0 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓
統計

תיאור הבעיה

Snakebite הוא הקלף החזק ביותר במשחק Slay the Spire 2, ו-Yuki נהנית להשתמש בו כדי להביס אויבים.

המשחק נמשך $10^{1000}$ תורות. בתחילת המשחק, לאויב יש $0$ שכבות של רעל.

ל-Yuki יש בסך הכל $n$ קלפי Snakebite. ההשפעה של קלף ה-Snakebite ה-$i$ היא: כאשר משחקים אותו, הוא מגדיל את שכבות הרעל של האויב ב-$v_i$. Yuki תשחק את קלף ה-Snakebite ה-$i$ בתחילת התור ה-$t_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.