CF452D.Washer, Dryer, Folder

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have k pieces of laundry, each of which you want to wash, dry and fold. You are at a laundromat that has _n_1 washing machines, _n_2 drying machines and _n_3 folding machines. Each machine can process only one piece of laundry at a time. You can't dry a piece of laundry before it is washed, and you can't fold it before it is dried. Moreover, after a piece of laundry is washed, it needs to be immediately moved into a drying machine, and after it is dried, it needs to be immediately moved into a folding machine.

It takes _t_1 minutes to wash one piece of laundry in a washing machine, _t_2 minutes to dry it in a drying machine, and _t_3 minutes to fold it in a folding machine. Find the smallest number of minutes that is enough to wash, dry and fold all the laundry you have.

你有 kk 件待洗衣物,每件都需要经过洗涤、烘干和折叠三个步骤。你所在的一家自助洗衣店共有 n1n_1 台洗衣机、n2n_2 台烘干机和 n3n_3 台折叠机。每台机器一次只能处理一件衣物。一件衣物必须先洗涤,然后才能烘干;也必须先烘干,然后才能折叠。此外,一件衣物一旦完成洗涤,就必须立即送入一台烘干机;一旦完成烘干,就必须立即送入一台折叠机。

在一台洗衣机中洗涤一件衣物需要 t1t_1 分钟,在一台烘干机中烘干一件衣物需要 t2t_2 分钟,在一台折叠机中折叠一件衣物需要 t3t_3 分钟。求完成全部 kk 件衣物的洗涤、烘干和折叠所需的最短时间(单位:分钟)。

输入格式

The only line of the input contains seven integers: k, _n_1, _n_2, _n_3, _t_1, _t_2, _t_3 (1 ≤ k ≤ 104; 1 ≤ _n_1, _n_2, _n_3, _t_1, _t_2, _t_3 ≤ 1000).

输入仅有一行,包含七个整数:kk、n1n_1、n2n_2、n3n_3、t1t_1、t2t_2、t3t_3(其中 1≤k≤1041 \leq k \leq 10^4;1≤n1,n2,n3,t1,t2,t3≤10001 \leq n_1, n_2, n_3, t_1, t_2, t_3 \leq 1000)。

输出格式

Print one integer — smallest number of minutes to do all your laundry.

输出一个整数——完成所有洗衣任务所需的最少分钟数。

输入输出样例

  • 输入#1

    1 1 1 1 5 5 5

    输出#1

    15
  • 输入#2

    8 4 3 2 10 5 2

    输出#2

    32

说明/提示

In the first example there's one instance of each machine, each taking 5 minutes to complete. You have only one piece of laundry, so it takes 15 minutes to process it.

In the second example you start washing first two pieces at moment 0. If you start the third piece of laundry immediately, then by the time it is dried, there will be no folding machine available, so you have to wait, and start washing third piece at moment 2. Similarly, you can't start washing next piece until moment 5, since otherwise there will be no dryer available, when it is washed. Start time for each of the eight pieces of laundry is 0, 0, 2, 5, 10, 10, 12 and 15 minutes respectively. The last piece of laundry will be ready after 15 + 10 + 5 + 2 = 32 minutes.

在第一个例子中,每种机器各有一台,每台完成任务均需 5 分钟。你只有一件待洗衣物,因此处理它总共需要 15 分钟。

在第二个例子中,你在时刻 0 开始清洗前两件衣物。若立即开始清洗第三件衣物,则当它完成烘干时将没有折叠机可用,因此你必须等待,并在时刻 2 才开始清洗第三件衣物。类似地,你无法在时刻 5 之前开始清洗下一件衣物,否则当该衣物清洗完毕时将没有烘干机可用。八件衣物各自的开始清洗时刻分别为 0、0、2、5、10、10、12 和 15 分钟。最后一件衣物将在 15+10+5+2=3215 + 10 + 5 + 2 = 32 分钟后完成。

输入解题思路,AI测评打分。不知道怎么写?

首页