Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4. int main()
  5. {
  6.         for (int i = 0; i < 1000; i++)
  7.         {
  8.                 int n;
  9.                 cin >> n;
  10.                 int* t = new int[n];
  11.                 char c;
  12.                 for (int j = 0; j < n; j++)
  13.                         cin >> c >> t[j];
  14.                 sort(t, t + n);
  15.                 int ile_poj = t[n - 1] / 32 + 1;
  16.                 int* p = new int[ile_poj];
  17.                 for (int j = 0; j<ile_poj; j++)
  18.                         p[j] = 0;
  19.                 for (int j = 0; j < n; j++)
  20.                 {
  21.                         int ktory_poj = t[j] / 32;
  22.                         p[ktory_poj] = p[ktory_poj] | 1 << (t[j] % 32);
  23.                 }
  24.                 int seeked;
  25.                 cin >> c >> seeked;
  26.                 if (seeked <= t[n - 1] && p[seeked / 32] & (1 << (seeked % 32)))
  27.                         cout << 1 << endl;
  28.                 else
  29.                         cout << 0 << endl;
  30.                 delete[] p;
  31.                 delete[] t;
  32.         }
  33.         return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement