Zoj 3778 Talented Chef greedy

Source: Internet
Author: User

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

   

  

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.