You are viewing a single comment's thread. Return to all comments →
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int N {0} ; int num {0} ; int qN {0} ; int qNum {0} ; int indx {0} ; vector<int> arr ; cin>> N ; for(int i = 0; i < N; i++) { cin >> num ; arr.push_back(num) ; } cin>> qN ; for (int i = 0; i < qN; i++) { cin >> qNum ; indx = lower_bound( arr.begin(), arr.end(), qNum ) - arr.begin() ; if( arr[indx] == qNum ) { cout << "Yes" ; } else { cout << "No" ; } cout << ' ' << indx + 1 << '\n' ; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Lower Bound-STL
You are viewing a single comment's thread. Return to all comments →