zoj 3778 Talented Chef (思维)
来源:互联网 发布:oa办公系统java源代码 编辑:程序博客网 时间:2024/05/18 00:32
As we all know, Coach Gao is a talented chef, because he is able to cook M dishes in the same time. Tonight he is going to have a hearty dinner with his girlfriend at his home. Of course, Coach Gao is going to cook all dishes himself, in order to show off his genius cooking skill to his girlfriend.
To make full use of his genius in cooking, Coach Gao decides to prepare N dishes for the dinner. The i-th dish contains Ai steps. The steps of a dish should be finished sequentially. In each minute of the cooking, Coach Gao can choose at most M different dishes and finish one step for each dish chosen.
Coach Gao wants to know the least time he needs to prepare the dinner.
题意:一个人可以在一分钟同时进行m道菜的一个步骤,共有n道菜,每道菜各有xi个步骤,求做完的最短时间。
分析:一开始 考虑的是做菜的顺序然后入坑了,其实根本不用考虑顺序,因为工作消耗的量是必然的。所以每分钟都可以消耗m的量,然后求平均值,如果还有余的,加1也必然能怼完,但是这个最短时间不能比最大的量单独做的时间更短。
#include <bits/stdc++.h>using namespace std;int main(){ int t; cin>>t; while(t--) { int n,m; scanf("%d%d",&n,&m); int maxx=0; int sum=0; for(int i=0;i<n;i++) { int d; scanf("%d",&d); maxx=max(maxx,d); sum+=d; } if(n<=m) { printf("%d\n",maxx ); continue; } else{ int ans=sum/m; if(sum%m) ans++; ans=max(ans,maxx); printf("%d\n",ans ); } }}
- zoj 3778 Talented Chef (思维)
- ZOJ 3778 Talented Chef
- 【zoj】 3778 Talented Chef
- zoj 3778 Talented Chef
- ZOJ 3778 Talented Chef
- zoj 3778 Talented Chef
- ZOJ 3778 Talented Chef
- ZOJ 3778 Talented Chef
- ZOJ 3778 Talented Chef
- ZOJ 3778 Talented Chef
- ZOJ 3778Talented Chef
- zoj 3778 Talented Chef
- ZOJ 3778 Talented Chef(数学啊 )
- ZOJ 3778 Talented Chef(计算器模拟)
- ZOJ 3778 Talented Chef (贪心)
- 贪心(ZOJ 3778,Talented Chef)
- zoj 3778 Talented Chef 模拟
- zoj 3778 Talented Chef 贪心
- linux shell 流程控制
- 顺序栈的完整实现
- JavaScript中格式化Date类型
- 入坑CSDN
- Unity3D游戏学习笔记2
- zoj 3778 Talented Chef (思维)
- 惰性求值和yield-Python
- Java基础知识总结(二)
- 181_08_IO流_FileInputStream_01
- 通过GDB调试理解GOT/PLT
- 没事玩玩leetcode周赛 #30~#34 #40 #42~#48 #50~#54 #56 #58 #59 60 #61
- 初学凸包(凸包学习总结)
- JavaScript学习笔记32-利用循环遍历数组元素
- 使用JDK自带的工具wsimport解析WSDL文件