Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- for (int i = 0; i < 1000; i++)
- {
- int n;
- cin >> n;
- int* t = new int[n];
- char c;
- for (int j = 0; j < n; j++)
- cin >> c >> t[j];
- sort(t, t + n);
- int ile_poj = t[n - 1] / 32 + 1;
- int* p = new int[ile_poj];
- for (int j = 0; j<ile_poj; j++)
- p[j] = 0;
- for (int j = 0; j < n; j++)
- {
- int ktory_poj = t[j] / 32;
- p[ktory_poj] = p[ktory_poj] | 1 << (t[j] % 32);
- }
- int seeked;
- cin >> c >> seeked;
- if (seeked <= t[n - 1] && p[seeked / 32] & (1 << (seeked % 32)))
- cout << 1 << endl;
- else
- cout << 0 << endl;
- delete[] p;
- delete[] t;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement