QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 2048 MB

#22870. נגד ההידרה

Statistics

הידרה בעלת $N$ ראשים הופיעה. לראש ה-$i$ יש בתחילה $H_i$ נקודות חיים.

באפשרותך לבצע התקפות מספר כלשהו של פעמים, כולל אפס. בכל התקפה, בחר אחד מבין $N + 1$ הסוגים הבאים:

  • התקפה $i$ ($1 \le i \le N$): הקטן את נקודות החיים של הראש ה-$i$ ב-$X$.
  • התקפה $N + 1$: הקטן את נקודות החיים של כל ראש ב-$Y$.

מצא את המספר המינימלי של התקפות הנדרש כדי להביא את נקודות החיים של כל ראש לכל היותר ל-$0$.

קלט

הקלט מכיל מקרה בדיקה אחד או יותר. השורה הראשונה של הקלט מכילה מספר שלם $T$ ($1 \le T \le 100$), שהוא מספר מקרי הבדיקה. אחריה מופיעים התיאורים של $T$ מקרי הבדיקה, כל אחד בפורמט הבא.

$$ \begin{aligned} &N\ X\ Y \\ &H_1\ H_2\ \ldots\ H_N \end{aligned} $$

עבור כל מקרה בדיקה, השורה הראשונה מכילה שלושה מספרים שלמים $N$, $X$ ו-$Y$ ($1 \le N \le 3 \times 10^5$, $1 \le X, Y \le 10^{18}$), המייצגים את מספר הראשים, הנזק שנגרם על ידי התקפה $i$ ($1 \le i \le N$), והנזק שנגרם על ידי התקפה $N + 1$, בהתאמה.

השורה השנייה מכילה $N$ מספרים שלמים $H_1, H_2, \ldots, H_N$ ($1 \le H_i \le 10^{18}$), כאשר $H_i$ מייצג את נקודות החיים ההתחלתיות של הראש ה-$i$.

סכום ערכי $N$ על פני כל מקרי הבדיקה אינו עולה על $3 \times 10^5$.

פלט

עבור כל מקרה בדיקה, הדפס מספר שלם יחיד המייצג את המספר המינימלי של התקפות הנדרש כדי להביא את נקודות החיים של כל ראש לכל היותר ל-$0$.

דוגמאות

קלט 1

2
3 5 2
12 6 17
1 998244353 1000000007
1000000007

פלט 1

7
1

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.