Codeforces Round #280 (Div. 2)

Source: Internet
Author: User

B. Vanya and Lanterns

Test instructions: give N street lamp, the length of street, find out the minimum irradiation radius of street lamp, make whole street be illuminated.

Figure out the distance from the starting point to the first lamp---the distance between the N lamps/2---the distance from the last lamp to the end of the street, find out the maximum value of these values.

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6 using namespacestd;7 8typedefLong LongLL;9 inta[10005],b[10005];Ten  One intMain () A { -     intn,l,i,x,y; -     DoubleD; theCin>>n>>l; -      for(i=1; i<=n;i++) cin>>A[i]; -Sort (A +1, a+n+1); -     intmaxd=-1; +      for(i=1; i<n;i++) -     { +b[i]=a[i+1]-A[i];  AMaxd=Max (maxd,b[i]); at     } -x=a[1]-0; -y=l-A[n]; - //printf ("x=%d\n", x); - //printf ("y=%d\n", y); - //printf ("maxd=%d\n", maxd); in if(2*x>maxd&&x>=y) printf ("%.7lf\n", x*1.0); - Else if(y>=x&&2*y>maxd) printf ("%.7lf\n", y*1.0); to       + Elseprintf"%.7lf\n", maxd*0.5); -      the}
View Code

C. Vanya and Exams

Test instructions: Give the N-field test, each exam can only test the highest score R, the average sub-give now each exam results a[i], improve a point need to do the test b[i], ask at least how many papers to do each branch to achieve the average score

First according to B[i] from small to large order, and then calculate the number of papers to be done, simulated to do paper

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6 using namespacestd;7 8typedefLong LongLL;9 structnode{Ten     intx, y; One} a[100005]; A  - intCMP (node N1,node n2) { -     if(N1.Y!=N2.Y)returnn1.y<n2.y; the     returnn1.x<n2.x; - } -  - intMain () + { -LL tmp=0, sum=0, ans=0, C,i, N,r,avg; +Cin>>n>>r>>avg; A      for(i=1; i<=n;i++) { atCin>>a[i].x>>a[i].y; -sum+=a[i].x; -     } -Sort (A +1, a+n+1, CMP); -ans=n*avg-sum; -      in //For (i=1;i<=n;i++) - //    { to //printf ("%d%d\n", a[i].x,a[i].y); + //    } - //printf ("ans=%d\n\n", ans); the     if(ans<=0) printf ("0\n"); *     Else $     {Panax Notoginseng          for(i=1; i<=n;i++){ -             if(R-ans<=a[i].x)) { thetmp+=ans*a[i].y; +C=ans; A             } the             Else{ +tmp+= (r-a[i].x) *a[i].y; -c=r-a[i].x; $             } $ans=ans-C; -             if(ans<=0) Break; -         } theprintf"%i64d\n", TMP);  -     }Wuyi}
View Code

D. Vanya and Computer Game

Test instructions: Give n monsters, Vanya play Strange frequency for X times per second, the damage to the monster is 1/x Vova play the frequency of Y times per second, to blame for the damage is 1/y give each monster the maximum number of times to be hurt asked the first monster who was defeated by WHO

See the Puzzle = =

Can be converted to Vanya every Y seconds to damage a monster, Vova every x seconds to damage a monster and then on the timeline to find the number of attacks, it must be X or Y or both divisible

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <algorithm>6 using namespacestd;7 8typedefLong LongLL;9 LL i,n,x,y,l,r,m,atk,a;Ten  One voidbsearch (LL a) A { -L=1, r=1e15; -      while(l<R) { theM= (L+R)/2; -atk=m/y+m/x; -         if(atk>=a) r=m; -         Elsel=m+1; +     } -     if(l%x==0&&l%y==0) printf ("both\n"); +     Else if(l%x==0) printf ("vova\n"); A     Elseprintf"vanya\n"); at } -  - intMain () - { -Cin>>n>>x>>y; -      for(i=1; i<=n;i++){ inCin>>A; - bsearch (a); to     } +     return 0;  -}
View Code

Say this is to do the first CF eh----at that time to do a when found to be a formula = =1+ (1+2) + (1+2+3)---Remember is equal to 6 per cent how much---Baidu to after, hand over = = actually too (good excitement)

Come on,-----go--go--go.

Codeforces Round #280 (Div. 2)

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.