Advertisement
Guest User

você é linda!

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