Advertisement
erfanul007

[UVa 10611] The Playboy Chimp

Nov 2nd, 2018
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. long long int n,q,i,j,a[50009];
  5. long long int x,min,max;
  6. scanf("%lld",&n);
  7. for(i=1;i<=n;i++){
  8. scanf("%lld",&a[i]);
  9. }
  10. scanf("%lld",&q);
  11. for(i=1;i<=q;i++){
  12. scanf("%lld",&x);
  13. min=999999999;
  14. max=0;
  15. for(j=1;j<=n;j++){
  16. if(a[j]>max && a[j]<x)
  17. max=a[j];
  18. if(a[j]<min && a[j]>x)
  19. min=a[j];
  20. }
  21. if(max==0 && min==999999999)
  22. printf("X X\n");
  23. else{
  24. if(max!=0 && min==999999999)
  25. printf("%lld X\n",max);
  26. else if(max==0 && min!=999999999)
  27. printf("X %lld\n",min);
  28. else
  29. printf("%lld %lld\n",max,min);
  30. }
  31. }
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement