You are viewing a single comment's thread. Return to all comments →
C++
int main() { int N, Q; cin >> N; vector<int> sorted(N); for (int i = 0; i < N; i++) cin >> sorted[i]; cin >> Q; vector<int> query(Q); for (int i = 0; i < Q; i++) cin >> query[i]; for (auto x : query) { auto result = lower_bound(sorted.begin(),sorted.end(),x); if(*result==x) cout<<"Yes "+to_string(result-sorted.begin()+1)<<endl; else cout<<"No "+to_string(result-sorted.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 →
C++