Advertisement
Guest User

Untitled

a guest
Dec 13th, 2010
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <cstdio>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     vector<int> a;
  9.     int x, n, q, k = 1;
  10.     while (true) {
  11.         scanf("%d%d", &n, &q);
  12.         if (n == 0 && q == 0) {
  13.             break;
  14.         }
  15.         a.assign(10001, 0);
  16.  
  17.         for (int i = 0; i < n; i++) {
  18.             scanf("%d", &x);
  19.             a[x]++;
  20.         }
  21.  
  22.         int num = 1;
  23.         for (int i = 0; i <= 10000; i++) {
  24.             if (a[i] > 0) {
  25.                 x = num + a[i];
  26.                 a[i] = num;
  27.                 num = x;
  28.             }
  29.         }
  30.  
  31.         printf("CASE# %d:\n", k++);
  32.         for (int i = 0; i < q; i++) {
  33.             scanf("%d", &x);
  34.             if (a[x] == 0) {
  35.                 printf("%d not found\n", x);
  36.             } else {
  37.                 printf("%d found at %d\n", x, a[x]);
  38.             }
  39.         }
  40.     }
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement