zoukankan      html  css  js  c++  java
  • zoj 3778 Talented Chef(思维题)

    题目

    题意:一个人可以在一分钟同时进行m道菜的一个步骤,共有n道菜,每道菜各有xi个步骤,求做完的最短时间。

    思路:一道很水的思维题, 根本不需要去 考虑模拟过程 以及先做那道菜(比赛的时候就是这么考虑的)。

    只是需要判断总数的平均值 和 耗时最大的一道菜 哪个最大。。

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <cstring>
     5 #include <cmath>
     6 #include <algorithm>
     7 using namespace std;
     8 
     9 int main()
    10 {
    11     int n, m, x;
    12     int t, sum, Max, ans;
    13     while(cin>>t)
    14     {
    15         while(t--)
    16         {
    17             cin>>n>>m;
    18             sum = 0; Max = -1;
    19             while(n--)
    20             {
    21                 cin>>x;
    22                 sum += x;
    23                 if(Max < x)
    24                     Max = x;
    25             }
    26             if(sum%m==0)
    27                 ans = sum/m;
    28             else
    29                 ans = sum/m+1;
    30             if(Max > ans)
    31                 ans = Max;
    32             cout<<ans<<endl;
    33         }
    34     }
    35     return 0;
    36 }
  • 相关阅读:
    Power of Cryptography
    Radar Installation
    Emag eht htiw Em Pleh
    Help Me with the Game
    89. Gray Code
    87. Scramble String
    86. Partition List
    85. Maximal Rectangle
    84. Largest Rectangle in Histogram
    82. Remove Duplicates from Sorted List II
  • 原文地址:https://www.cnblogs.com/bfshm/p/3662811.html
Copyright © 2011-2022 走看看