Lower Bound-STL

  • + 0 comments

    I Dont know why everyone is confusing, the most simplest answer..

    int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n ; cin >> n; vectornums(n); for(int i = 0;i> nums[i]; }

    int q;
    cin >> q;
    while(q--)
    {
        int target;
        cin >> target;
        auto it = lower_bound(nums.begin(),nums.end(),target);
        if(*it == target)
        {
            cout << "Yes " <<  it-nums.begin()+1 << endl;
        }
        else {
            cout << "No " << it-nums.begin()+1<<endl;
        }
    }
    return 0;
    

    }