Advertisement
royalsflush

Referência para Lawn Mower (LA 4954)

Jul 1st, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int nx,ny;
  6. double w;
  7. double x[1010];
  8. double y[1010];
  9.  
  10. double checkGrass(double p[], int pn) {
  11.     double last=0.0;
  12.     sort(p,p+pn);
  13.    
  14.     for (int i=0; i<pn; i++)
  15.         if (last>=p[i]-w/2.0)
  16.             last=p[i]+w/2.0;
  17.         else
  18.             break;
  19.     return last;
  20. }
  21.  
  22. int main() {
  23.     while (1) {
  24.         scanf("%d %d %lf", &nx,&ny,&w);
  25.            
  26.         if (!nx && !ny && !w)
  27.             break;
  28.  
  29.         for (int i=0; i<nx; i++)
  30.             scanf("%lf", &x[i]);
  31.  
  32.         for (int i=0; i<ny; i++)
  33.             scanf("%lf", &y[i]);
  34.  
  35.         if (checkGrass(x,nx)>=75.0 &&
  36.                 checkGrass(y,ny)>=100.0)
  37.             printf("YES\n");
  38.         else
  39.             printf("NO\n");
  40.     }
  41.  
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement