Codeforces Round #335 (Div. 1)--c. Freelancer ' s Dreams linear programming dual problem + three points

Source: Internet
Author: User

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

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.