QOJ.ac

QOJ

Time Limit: 4 s Memory Limit: 2048 MB Total points: 100

#10340. Damage per Second

統計

你刚刚在你最喜欢的角色扮演游戏中创建了一个新角色,现在需要决定如何为他分配技能。

需要选择的两个技能属性是:单次伤害和每秒攻击次数。单次伤害是你单次攻击造成的伤害量,而每秒攻击次数是你在一秒内可以进行的攻击次数。初始时,两个技能属性均为 0。你有 $k$ 个技能点可以随意分配;换句话说,你可以选择两个技能的值,使它们为正整数且之和不超过 $k$。

游戏教程(你想要尽快完成的无聊部分)包含 $n$ 个需要依次击杀的怪物。第 $i$ 个怪物的生命值为 $h_i$,即在你造成至少 $h_i$ 点伤害后它会死亡。

你应该如何分配这两个技能属性,以最小化击杀所有 $n$ 个怪物所需的时间?

输入格式

第一行包含两个整数 $n$ 和 $k$ ($1 \le n \le 200\,000$, $2 \le k \le 200\,000$) —— 敌人的数量和技能点的数量。

第二行包含 $n$ 个整数 $h_i$ ($1 \le h_i \le 10^{13}$) —— 第 $i$ 个敌人的生命值。

输出格式

输出两个正整数 $x$ 和 $y$ ($1 \le x, y$ 且 $x + y \le k$) —— 你想要投入到单次伤害和每秒攻击次数上的技能点数。如果存在多个最优解,输出其中任意一个即可。

样例

输入 1

1 7
14

输出 1

3 4

说明 1

只有一个怪物,你有 7 个技能点可以分配。如果你设置单次伤害为 3,你需要 5 次攻击才能击杀它。如果你设置每秒攻击次数为 4,你需要 1.25 秒来击败怪物。没有比这更快击败怪物的方法了。

输入 2

4 9
1 2 3 4

输出 2

4 5

说明 2

如果你在单次伤害上分配 4 个技能点,在每秒攻击次数上分配剩余的 5 个点,你对每个怪物只需要一次攻击,总时间为 0.8 秒。

输入 3

5 13
3 4 5 6 7

输出 3

7 6

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.