SHARE
TWEET

Untitled

a guest Jan 17th, 2020 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n,q;
  6.     while(scanf("%d%d",&n,&q))
  7.     {
  8.         if(!n)
  9.         {
  10.             return 0;
  11.         }
  12.         static int qrn=1;
  13.         printf("CASE# %d:\n",qrn++);
  14.         int arr[n];
  15.         for(int i=0;i<n;i++)
  16.         {
  17.             scanf("%d",&arr[i]);
  18.         }
  19.         sort(arr,arr+n);
  20.         for(int i=0;i<q;i++)
  21.         {
  22.             int key;
  23.             scanf("%d",&key);
  24.             int vl=(lower_bound(arr,arr+9,key))-arr;
  25.             if(arr[vl]==key)
  26.             {
  27.                printf("%d found at %d\n",key,vl+1);
  28.             }
  29.             else {
  30.                 printf("%d not found\n",key);
  31.             }
  32.  
  33.         }
  34.         n--;
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top