首页 > 代码库 > ZOJ 3778: Talented Chef

ZOJ 3778: Talented Chef

ZOJ - 3778

///@author Sycamore, ZJNU
///@accepted_on 2017 - 01 - 17
///
#include<iostream>
#include<algorithm>
#include<algorithm>
using namespace std;
int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        int N, M, t;
        long long sum = 0;
        int m = 0;
        cin >> N >> M;
        while (N--)
        {
            cin >> t;
            m = max(t, m);
            sum += t;
        }
        int ans;
        if (sum%M) ans = sum / M + 1;
        else ans = sum / M;
        ans = max(ans, m);
        cout << ans << endl;
    }
    return 0;
}

 

ZOJ 3778: Talented Chef