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