QOJ.ac

QOJ

시간 제한: 1.0 s 메모리 제한: 2048 MB 총점: 100

#15924. 小调度

통계

如今,每个人都在关注云计算,因此人们正在尝试许多不同的商业模式。你正在尝试一种非常简单的模式:你以两种被称为“时间片”的批次之一出售机器上的时间。客户可以购买 $1$ 秒的 CPU 时间,或者购买 $Q$ 秒(其中 $Q$ 为某个整数)。

客户购买的每个时间片都必须在单台机器上完成,但你可以决定如何在机器之间分配这些已购买的时间片。

度过一个漫长的假期回来后,你发现你所有的机器都处于空闲状态,并且有各种各样的订单送达。为了让客户满意,你必须决定如何在机器之间分配这些请求,以使所有已购买的时间片最终全部完成的时间最小化。

完成所有已购买的时间片所需的最短时间是多少?

输入格式

输入由单行组成,包含四个整数:

  • $Q$($2 \le Q \le 1\,000$),表示完成较长批次所需的时间;
  • $M$($1 \le M \le 1\,000\,000$),表示你公司拥有的机器数量;
  • $S$($0 \le S \le 1\,000\,000$),表示购买的 $1$ 秒时间片的数量;
  • $L$($0 \le L \le 1\,000\,000$),表示购买的 $Q$ 秒时间片的数量。

输出格式

输出完成所有已购买的时间片所需的最短时间。

样例

输入格式 1

2 4 3 6

输出格式 1

4

输入格式 2

3 4 3 5

输出格式 2

6

输入格式 3

10 2 0 1

输出格式 3

10

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.