Test instructions: P, q, all integers.
Sigma (Ai * ki) >= p,
Sigma (Bi * ki) >= q;
ans = Sigma (ki). Minimum value for output ans
constraints of 2, but the variable K has 100,000, so you can use duality to convert to Solving
Ans = p * y1 + q * y2
The constraints are:
Ai * y1 + Bi * y2 <= 1 where I is 0~n-1
That is, the n constraint condition. It's just a three-point back.
1#include <bits/stdc++.h>2 using namespacestd;3 Const intMAXN = 1e5 +5;4 DoubleA[MAXN], B[MAXN], p, q;5 intN;6 DoubleCheckDoublex) {7 Doubley =1e20;8 for(inti =0; I < n; i++){9y = min (Y, (1-A[I]*X)/b[i]);Ten } One returnp * x + y *Q; A } - intMain () - { the #ifndef Online_judge -Freopen ("In.txt","R", stdin); - #endif - while(~SCANF ("%D%LF%LF", &n, &p, &q)) { + for(inti =0; I < n; i++){ -scanf"%LF%LF", A+i, B +i); + } A DoubleL =0, r =1.0/(*max_element (A, A +n)); at for(inti =0; I < -; i++){ - Doubleml = (L + L + R)/3; - DoubleMr = (R + R + L)/3; - if(check (ML) >Check (MR)) { -R =Mr; -}Else{ inL =ml; - } to } +printf"%.20f\n", check ((l+l)/2)); - } the return 0; *}
Codeforces Round #335 (Div. 1)--c. Freelancer ' s Dreams linear programming dual problem + three-part