码迷,mamicode.com
首页 > 其他好文 > 详细

zoj 3778 Talented Chef

时间:2014-11-02 16:11:16      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   ar   os   for   sp   

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5265

先确定n和m的大小,m大就输出最大值就可以。否则比较sum/m和max1的大小。

bubuko.com,布布扣
 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     int t;
 9     scanf("%d",&t);
10     while(t--)
11     {
12         int n,m;
13         scanf("%d%d",&n,&m);
14         int sum=0,max1=0;
15         for(int i=1; i<=n; i++)
16         {
17             int x;
18             scanf("%d",&x);
19             sum+=x;
20             max1=max(max1,x);
21         }
22         int ans=0;
23         if(sum%m)
24         {
25             ans=sum/m+1;
26         }
27         else
28             ans=sum/m;
29         if(max1>ans)
30             ans=max1;
31         if(n>=m)
32         {
33             printf("%d\n",ans);
34         }
35         else
36         {
37             printf("%d\n",max1);
38         }
39     }
40     return 0;
41 }
View Code

 

zoj 3778 Talented Chef

标签:style   blog   http   io   color   ar   os   for   sp   

原文地址:http://www.cnblogs.com/fanminghui/p/4069325.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!