You are viewing a single comment's thread. Return to all comments →
// cleanest solution IMO
int main() { int n, q; std::cin >> n; std::vector<int> vec(n); for (auto &i : vec) std::cin >> i; std::cin >> q; for (int i = 0; i < q; i++) { int n; std::cin >> n; auto it = std::lower_bound(vec.begin(), vec.end(), n); if (*it == n) std::cout << "Yes "; else std::cout << "No "; std::cout << (it - vec.begin()) + 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 →
// cleanest solution IMO