A9473 | Washer, Dryer, Folder
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
The only line of the input contains seven integers: $k,n_{1},n_{2},n_{3},t_{1},t_{2},t_{3}$ $(1<=k<=10^{4}; 1<=n_{1},n_{2},n_{3},t_{1},t_{2},t_{3}<=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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted