这题的意思是给你 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. [LeetCode]题解(python):115-Distinct Subsequences

    题目来源: https://leetcode.com/problems/distinct-subsequences/ 题意分析: 给定字符串S和T,判断S中可以组成多少个T,T是S的子串. 题目思路: ...

  2. Java解析器

    http://www.infoq.com/cn/articles/HIgh-Performance-Parsers-in-Java-V2?utm_source=infoq&utm_medium ...

  3. Struts2 中action之间的跳转(分享)

    例如从你的login.action到register.action  有两种实现方式 1. 设置type="redirect" <package  name="st ...

  4. elasearch 版本控制

    http://192.168.32.81:9200/library/books/8/ GET { "_index": "library", "_typ ...

  5. Win32 GDI基础(笔记)

    1.GDI名字的意义 GDI Graphic Device Interface,我说不清和GUI有什么区别.可能一种针对设备,一种针对用户而言吧,反正以后都说GDI,也就是Windows的图形编程. ...

  6. Sicily-1153 解题报告

    一.原题中文大意. 1      2       3      4       5      6         7     8 9     10       11    12      13    ...

  7. Hat’s Words(字典树)

    Hat’s Words Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  8. :before :after

    #p1:before{ content: "哈哈哈 "; color: red;}#p1:after{ content: "哈哈哈"; color: #452d ...

  9. 简简单单C#爬虫小计

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...

  10. 设计模式值六大原则——设计模式之六大原则——单一职责原则(SRP)

    定义: 应该有且仅有一个原因引起类的变更. There should never be more than one reason for a class to change. 优点: 1.类的复杂性降 ...