Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cstring>
- #include <algorithm>
- #include <map>
- using namespace std;
- typedef long long ll;
- int main()
- {
- int n;
- cin >> n;
- int niza[n];
- for(int i = 0; i < n; i++) {
- cin >> niza[i];
- }
- int x;
- cin >> x;
- int L = 0;
- int R = n - 1;
- while(L <= R) {
- int middle = (L + R) / 2;
- if(niza[middle] == x) {
- cout << "DA" << endl;
- break;
- }
- if(niza[middle] < x) {
- L = middle + 1;
- }
- else {
- R = middle - 1;
- }
- }
- return 0;
- }
- /*
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement