Advertisement
Farjana_akter

Untitled

Feb 2nd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,q,i,j,k,a[100000],b,t=0,c;
  7. while(1)
  8. {
  9. scanf("%d %d",&n,&q);
  10. if(n==0 && q==0)
  11. break;
  12. cout<<"CASE# "<<++t<<":"<<endl;
  13. for(i=0;i<n;i++)
  14. {
  15. cin>>a[i];
  16. }
  17. sort(a,a+n);
  18. for(i=0;i<q;i++)
  19. {
  20. cin>>b;
  21. c=lower_bound(a,a+n,b)-a;
  22. if(a[c]==b)
  23. cout<<b<<" found at "<<++c<<endl;
  24. else
  25. cout<<b<<" not found"<<endl;
  26. }
  27.  
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement