这题的意思是给你 n 道菜,第 i 道菜需要 Ai 步才能完成

每次你能对 m 道菜分别完成一步,请问最少需要几次?

这题暴力写肯定是不行的,去年省赛的时候就是没写出来这题,今天再把思路理一理吧。

首先我们需要明确的是

1. n <= m 的时候, 那么答案显而易见,就是 Max (A[i])

2. n > m

  ①此时我们不难发现这个现象,如果 sum (A[i]) 能被 m 整除,那么我们可能恰恰只需要 (sum / m) 次即可完成

    一个例子: n = 3, m = 2

         a[1] = 1, a[2] = 2, a[3] = 3

  

  ②如果,sum (A[i]) 不能被 m 整除,那么只需要在 ① 的基础上加1即可

当然,这里不能忘了,在答案输出的时候,要保证答案 >= Max(A[i]), 否则会出现对一个 A[i] 多次减法操作

贴上 Source Code:

 #include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <algorithm> using namespace std; int a[];
int n, m; int main (){
int i, j, k, u, v, t; cin >> t;
while (t--) {
cin >> n >> m;
int sum = ;
int MAX = ;
for (i = ; i < n; ++i){
cin >> a[i];
sum += a[i];
MAX = max (MAX, a[i]);
} if (n <= m) {
cout << MAX << endl;
continue;
} int cur = sum / m;
if (sum % m != ) ++cur; cur = max(cur, MAX); cout << cur << endl;
} return ;
}

ZOJ 3778 Talented Chef 模拟 [ 祝愿明天省赛一帆风顺, ZJSU_Bloom WILL WIN : )的更多相关文章

  1. ZOJ 3778 Talented Chef(找规律,模拟计算,11届ACM省赛,简单)

    题目链接 2014年浙江省赛C题,当时觉得难,现在想想这题真水.. 找规律: 若   最大的那个步骤数*m-总和>=0,那么答案就是 最大的那个步骤数 . 否则  就要另加上不够的数量,具体看代 ...

  2. zoj 3778 Talented Chef(思维题)

    题目 题意:一个人可以在一分钟同时进行m道菜的一个步骤,共有n道菜,每道菜各有xi个步骤,求做完的最短时间. 思路:一道很水的思维题, 根本不需要去 考虑模拟过程 以及先做那道菜(比赛的时候就是这么考 ...

  3. ZOJ 3778 Talented Chef

    题目链接 题意 : 这个人需要做n道菜,每道菜Ai步,他可以同时做M道不同的菜的其中一步,问你最少需要多少时间能做完所有的菜. 思路 : 这个题比赛的时候禁锢思路了,根本没想出来,就是当M > ...

  4. ZOJ 3778 Talented Chief

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3778 题目 某人做菜很厉害,一分钟能同时完成最多m个菜的一道工序,输入菜的 ...

  5. Talented Chef ZOJ - 3778

    As we all know, Coach Gao is a talented chef, because he is able to cook M dishes in the same time. ...

  6. ZOJ 3778:Talented Chef(贪心?思维)

    Talented Chef Time Limit: 2 Seconds Memory Limit: 65536 KB As we all know, Coach Gao is a talented c ...

  7. Talented Chef(简单题,被我想的太复杂了,用复杂的方法当然会超时咯,由此可见,并非所有题都是想的越多越好)

    Description As we all know, Coach Gao is a talented chef, because he is able to cook M dishes in the ...

  8. zoj3778 Talented Chef

    As we all know, Coach Gao is a talented chef, because he is able to cook M dishes in the same time. ...

  9. ZOJ 3778 C - Talented Chef 水题

    LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3778 题意:有n道菜,每道菜需要\(a_i\)道工序,有m个锅可 ...

随机推荐

  1. codeforces 616E. Sum of Remainders 数学

    题目链接 给两个数n, m. 求n%1+n%2+.......+n%m的值. 首先, n%i = n-n/i*i, 那么原式转化为n*m-sigma(i:1 to m)(n/i*i). 然后我们可以发 ...

  2. sourceTree安装与使用

    1,下载并安装 sourceTree http://downloads.atlassian.com/software/sourcetree/windows/SourceTreeSetup_1.6.14 ...

  3. java集合分析(转载)

    参考文章:浅谈Java中的Set.List.Map的区别 Java 7 Collections详解 java中集合分为三类: Set(集) List(列表) Map(映射) Set和List继承自Co ...

  4. 【转】context和getApplicationContext()介绍

    在android中常常会遇到与context有关的内容,大多都是作为参数在传递,但是它的作用究竟是什么呢 先说它的用法,举个例子 在语句 AlertDialog.Builder builder = n ...

  5. C++模板:读入优化

    int scan(int &x){ while(c=getchar(),c<'0'||c>'9');x=c-'0'; while(c=getchar(),c>='0'& ...

  6. D - 金樽清酒斗十千(搜索dfs)

    D - 金樽清酒斗十千 Time Limit:2000MS     Memory Limit:524288KB     64bit IO Format:%I64d & %I64u Submit ...

  7. android service和activity的通讯

    我们须要用下面方式来启动service: </pre><pre name="code" class="java"><span st ...

  8. IE浏览器下<A>标签不能显示背景图片

    修改前 background: url('./img/active/legendBg.png')no-repeat 修改后 background: url('./img/active/legendBg ...

  9. MVC DI

    using System;using Microsoft.Practices.Unity; public class BizInstanceFactory { private static reado ...

  10. ssh登陆笔记📒

    ssh的配置 ssh的配置文件在/etc/ssh下,有两种配置文件,ssh_config和sshd_config. ssh_config是针对客户端的配置文件, sshd_config是针对服务端的配 ...