Zoj 3778 Talented Chef greedy
Question:
There are n cakes, and the time required for completing each pie is t1, t2 ,..., tn, now there are m pots (that is to say, you can fry m cakes at the same time), ask how long it will take to finish all the cakes.
Restrictions:
1 <= n, m, ti <= 40000
Ideas:
Greedy
Ans = max (ceil (sigma (1 ~ N, ti)/m), max (ti ))
/* Zoj 3778 Talented Chef: There are n cakes. The time required for completing each pie is t1, t2 ,..., tn, now there are m pots (that is to say, you can fry m cakes at the same time), ask how long it will take to finish all the cakes. Restrictions: 1 <= n, m, ti <= 40000 train of thought: greedy ans = max (ceil (sigma (1 ~ N, ti)/m), max (ti) */# include
# Include
Using namespace std; int main () {int T; scanf ("% d", & T); while (T --) {int n, m; scanf ("% d", & n, & m); int a; int sum = 0, _ max = 0; for (int I = 0; I