Wannafly Challenge D-applese's birthday

Source: Internet
Author: User

idea: first of all to be able to see, for each cake, if divided into k parts, must be the average score; then record the minimum weight, directly add these cakes to the priority queue, each time the queue to determine whether the first cake and the minimum ratio to meet the conditions can be

Code:

#include <bits/stdc++.h>using namespaceStdtypedef Long LongllConst intMAXN =1e5+10;Constll mod =998244353;intN, M;DoubleT, K, MN;structB =DoubleA, B;intNum D () {} d (DoubleADoubleBintnum): A (a), B (b), num (num) {}BOOL operator< (ConstD &t)Const{returnb < t.b; }};intMain () { while(~SCANF ("%LF %d", &t, &n)) {priority_queue<d> q;intAns =0; MN = mod; for(inti =0; I < n; i++) {scanf ("%LF", &k); Q.push (D (k, K,1));        mn = Min (mn, k); } while(!q.empty ()) {D d = q.top (); Q.pop ();if(mn/d.b >= T) Break;            d.num++;            D.B = D.a/d.num;            mn = min (d.b, MN);            ans++;        Q.push (d); } printf ("%d\n", ans); }return 0;}

Wannafly Challenge D-applese's birthday

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.