Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- #include<sstream>
- #include<string>
- #include<climits>
- using namespace std;
- int main() {
- /* Enter your code here. Read input from STDIN. Print output to STDOUT */
- cin.sync_with_stdio(false);
- cout.sync_with_stdio(false);
- int n;
- cin >> n;
- vector<int> v;
- int num, max_num = INT_MIN;
- for (int i = 0; i < n; i++) {
- cin >> num;
- if (num > max_num) {
- max_num = num;
- }
- v.push_back(num);
- }
- int n2;
- cin >> n2;
- for (int i = 0; i < n2; i++) {
- int number_to_search;
- cin >> number_to_search;
- if (number_to_search > max_num) {
- cout << "No " << v.size() << endl;
- }
- else {
- vector<int>::iterator it_low = lower_bound(v.begin(), v.end(), number_to_search);
- vector<int>::iterator it_up = upper_bound(v.begin(), v.end(), number_to_search);
- if (find(v.begin(), v.end(), number_to_search) != v.end()) {
- cout << "Yes " << it_low - v.begin() + 1 << endl;
- }
- else {
- cout << "No " << it_up - v.begin() + 1 << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement