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, n1; vector<int> vec; std::cin >> n; for (int i=0; i<n; i++) { std::cin >> n1; vec.push_back(n1); } std::cin >> n; for (int i=0; i<n; i++) { std::cin >> n1; auto result = std::lower_bound(vec.begin(), vec.end(), n1); std::cout << (*result == n1 ? "Yes " : "No ") << (result - vec.begin() + 1) << endl; } 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 →